본문 바로가기

2016/1010

MPI Function Dictionary MPI Function의 parameter와 MPI_Datatype, MPI_Reduce functions등을 나름대로 정리한 글입니다. MPI에 더 자세히 정리된 문서는 KISTI Lecture Note를 참고하세요: http://ap2.khu.ac.kr/download/mpi_lec.pdf 또는 각 Function들을 나열한 문서: MPI Routines 참조 Bone functions: - MPI_Init(&argc, &argv) - MPI_Comm_rank(MPI_Comm comm, int *rank) - MPI_Comm_size(MPI_Comm comm, int *size) - MPI_Finalize() MPI_Datatype: - MPI_CHAR: signed char - MPI_SHORT: .. 2016. 10. 4.
KSC 2015 3번 문제 및 풀이 sequential.c#include #include #include #include #include #include float ran2(long *); long iseed=-9; struct timeval tv; float gettime(){ static int startflag = 1; static double tsecs0, tsecs1; if(startflag) { (void ) gettimeofday(&tv, NULL); tsecs0 = tv.tv_sec + tv.tv_usec*1.0E-6; startflag = 0; } (void) gettimeofday(&tv, NULL); tsecs1 = tv.tv_sec + tv.tv_usec*1.0e-6; return (float) (tsecs1 - ts.. 2016. 10. 1.
KSC 2015 2번 문제 및 답안 sequential.c#include #include #include #include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /* int np = 30, ne = 512; */ int np = 5, ne = 10; // np: number of nodes in each element // ne: number of elements // caution: np 20, ne 256 will take approx 10 minutes on a serial job void interface_flux(double *qq, double *fstar, double *ib, double speed); void rhs(double *qq, double *rr, do.. 2016. 10. 1.
KSC 2015 1번 문제 및 답안 sequential.c#include #include #include double genvv(double x){ return (x*x+pow(x,4)+pow(x,6)+exp(-x*x)+cos(x)+sin(x)+tan(x)); } int main(int argc, char **argv){ int i,n1,n2,j,jsta,jend; int iter,niter; double xi,xf,dx; double tmr; double *ar, *br; /* Do not change */ n1 = 0; n2 = 100000000; niter = 3; /* Do not change */ ar = (double*) malloc(sizeof(double)*n2); br = (double*) malloc(sizeof(doub.. 2016. 10. 1.
KSC 2014 3번 문제 및 답안 sequential.c#include #include #include #include double time_diff(struct timeval t1, struct timeval t2) { double sec1, sec2; sec1 = t1.tv_sec + t1.tv_usec*1e-6; sec2 = t2.tv_sec + t2.tv_usec*1e-6; return sec2-sec1; } int build_house(int nx, int column, int site[]) { int num_sol = 0; bool is_sol; int i, j; // Try to build a house in each line of column for (i=0; i=0; j--) { if ((site[column] == si.. 2016. 10. 1.
KSC 2014 2번 문제 및 답안 sequential.c#include #include #include #include #include #include #include #define THRES 100000000 #define READY_STATE -111 #define WRITING_STATE -222 #define READY_TAG 111 #define NP_TAG 222 #define R_TAG 333 #define RSLT_TAG 444 #define BOX_TAG 555 typedef struct Pos{ float x,y,z; }Pos; double potential(Pos *r, int np, int jsta, int jend, int ista, int iend){ int i,j; double potent = 0; int fi.. 2016. 10. 1.
KSC 2014 1번 문제 및 답안 [문제] 아래에 주어진 편미분 방정식 풀이 방법으로 순차 프로그램이 주어져 있다. 주어진 풀이 방식은 유한차분 (finite-difference) 방법을 활용하는 것이다. 주어진 2차원 공간을 x, y 방향으로 각각 m, n개의 격자를 고려한다. 즉, x 방향으로 i=1,2,3,...,m (또는 0,1,2,...m-1)의 격자가 정의되고, y 방향으로도 j=1,2,3,...,n (또는 0,1,2,...,n-1)처럼 격자가 정의 된다. 2차원 공간은 [0,1] ╳ [0,1]로 주어진다. 여기서 x 방향 경계들, x=0, x=1은 각각 유한 격자 지수 i=1, i=m (또는 i=0, i=m-1)에 해당한다. 마찬가지로 y 방향으로도 동일한 조건을 활용한다. y=0, y=1은 각각 j=1, j=n (또는 j=.. 2016. 10. 1.
KSC 2013 3번 문제 및 답안 sequential.c#include #include #include void advance_field(int nx, int ny, double *f, double *g, double *c) { int i, j, idx; for (i=1; i 2016. 10. 1.
KSC 2013 2번 문제 및 답안 문제 다운로드 문제는 2차 FDM으로 2차 배열을 쪼개어 계산하는 것이다. Exchange Boundary function이 핵심적이라고 볼 수 있다.sequential.c#include #include #include void advance_field(int nx, int ny, double *f, double *g) { int i, j, idx; for (i=1; i 2016. 10. 1.
KSC 2013 1번 문제 및 답안 문제1Simpson 적분공식을 활용한 1차원 정적분 프로그램을 고려한다. 주어진 시작 프로그램(C 또는 FORTRAN)을 병렬화(MPI/OpenMP)시켜서 주어진 시스템에서 적분값과 총 함수 호출 횟수를 출력하시오. 또한, 최대 병렬 효율 성능을 구하시오. 여기서 사용된 Simpson 정적분 공식은 구간 [a,b]에 대한 정적분을 의미하고, n+1개의 함수값을 호출하게 되어 있다. 여기서 n은 짝수 이다. 실제 정적분값은 다음의 수식으로 근사된다. (h/3)[f(x0)+4f(x1)+2f(x2)+....+4f(xn-1)+f(xn)]. 여기서, h=(b-a)/n 이며, xi=a+ih이고, f(x)=4/(1+x2)이다. 주의할 점은 함수 호출을 n+1번만 수행한다. Simpson 적분공식은 검색해보면 이와 같.. 2016. 10. 1.