void* thread_function(void* thread_id) { int *temp = (int*)thread_id; int i, j = *temp; int k = 0, NUM_ITER = 50; get_data(j); printf("done getting data\n"); pthread_barrier_wait(&barr); #ifdef DUMP if(j == 0) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif for(k = 0; k < NUM_ITER; k++) { int half_point = DIMY/(2*NUM_TH); int elem_to_process = DIMY/NUM_TH; for(i = 1; i <= levels; i++) { haar2_step1(elem_to_process, j, half_point); half_point = half_point >> 1; elem_to_process = elem_to_process >> 1; } } // pthread_barrier_wait(&barr); #ifdef DUMP if(j == 15) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif /* //printf("Just after barrier %d\n", j); #ifdef DUMP if(j == 0) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif //printf("before writing image ID %d\n", j); writeImage(j); */ }
void do_dump_stats(int argc, char *argv[]) { uint64_t ints[2]; parse_int_args(argc, argv, ints, 2); m5_dump_stats(ints[0], ints[1]); }
int main(int argc, char *argv[]) { int rank; int n_ranks = 16; int n = 10; int END = 50; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &n_ranks); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Barrier(MPI_COMM_WORLD); // printf("crossing bar1 %d\n", rank); #ifdef DUMP if(rank == 0) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif for(n = 0; n < END; n++) { if(rank == 0) { u8 cipher_text[16] = {0xec,0xae,0xb0,0x2a,0xf2,0x51,0x45,0x25,0xb4,0x19,0x18,0x70,0x10,0x2,0x5,0x12}; rijndaelDecrypt_Master(decpt_rk, cipher_text, rank); } else if(rank == n_ranks - 1) { u8 decipher_text[16] = {0}; rijndaelDecrypt_Final(decpt_rk, decipher_text, rank); } else rijndaelDecrypt_Middle(decpt_rk, rank); } //printf("before bar2 %d\n", rank); MPI_Barrier(MPI_COMM_WORLD); //printf("done with thread %d\n", rank); MPI_Finalize(); return 0; }
/* * Runs benchmark. */ int main(int argc, char **argv) { int i; /* Loop index. */ int *map; /* Map of clusters. */ uint64_t end; /* End time. */ uint64_t start; /* Start time. */ vector_t *data; /* Data points. */ readargs(argc, argv); printf("CAPBench - KM kernel\n"); printf(" # of threads: %d \n", nthreads); timer_init(); srandnum(seed); omp_set_num_threads(nthreads); /* Benchmark initialization. */ start = timer_get(); data = smalloc(p->npoints*sizeof(vector_t)); for (i = 0; i < p->npoints; i++) { data[i] = vector_create(p->dimension); vector_random(data[i]); } end = timer_get(); /* Cluster data. */ printf("Entering in KM ROI - Clustering data...\n"); start = timer_get(); m5_reset_stats(0,0); map = kmeans(data, p->npoints, p->ncentroids, p->mindistance); end = timer_get(); m5_dump_stats(0,0); printf("KM total time: %f\n", timer_diff(start, end)*MICROSEC); /* House keeping. */ free(map); for (i = 0; i < p->npoints; i++) vector_destroy(data[i]); free(data); return (0); }
int main(int argc, char** argv) { int i, j; int nx = NX; int ny = NX; /* Variable declaration/allocation. */ double *A = (double *) malloc(ny*nx*sizeof(double)); double *s = (double *) malloc(ny*sizeof(double)); double *q = (double *) malloc(nx*sizeof(double)); double *r = (double *) malloc(ny*sizeof(double)); double *p = (double *) malloc(nx*sizeof(double)); for (i = 0; i < ny; i++) p[i] = i * M_PI; for (i = 0; i < nx; i++) { r[i] = i * M_PI; for (j = 0; j < ny; j++) A[i*nx + j] = ((double) i*(j+1))/nx; } m5_reset_stats(0,0); #pragma scop for (i = 0; i < nx; i++) s[i] = 0; for (i = 0; i < nx; i++) { q[i] = 0; for (j = 0; j < ny; j++) { s[j] = s[j] + r[i] * A[i*nx + j]; q[i] = q[i] + A[i*nx + j] * p[j]; } } #pragma endscop m5_dump_stats(0,0); printf("%f, %f, %f, %f, %f\n", A[11], p[11], q[11], r[11], s[11]); return 0; }
int main(int argc, char *argv[]) { int rank; int n_ranks = 6; int n = 10; int i; MPI_Init(&argc, &argv); #ifndef DUMP MPI_Comm_size(MPI_COMM_WORLD, &n_ranks); #endif MPI_Comm_rank(MPI_COMM_WORLD, &rank); //u8 decipher_text[16] = {0}; /* u8 rk[RK_LEN] = { 0x33, 0xc6, 0x6d, 0x09, 0x3e, 0x68, 0x5c, 0x0f, 0x63, 0x03, 0x13, 0x79, 0x92, 0x7c, 0x2a, 0x09, }; */ MPI_Barrier(MPI_COMM_WORLD); #ifdef DUMP if(rank == 0) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif int END = 1000; for(n = 0; n < END; n++) { if(rank == 0) { /* u8 plain_text[16] = { 0x25, 0x5c, 0x31, 0x1d, 0x71, 0xd8, 0x04, 0xb7, 0x43, 0x11, 0x40, 0x86, 0x12, 0xa2, 0xc8, 0x3d };*/ u8 cipher_text[16] = { 0x7d, 0x9a, 0xd4, 0x86, 0xfd, 0x60, 0x14, 0x4f, 0x57, 0xfd, 0x77, 0x94, 0xa3, 0xf2, 0xa0, 0xfb }; rijndaelDecrypt_Master(decpt_rk, cipher_text, rank); /* putchar('\n'); for (i = 0; i < 16; i++) { printf("0x%02x, ", plain_text[i]); } putchar('\n'); */ } else if(rank == n_ranks - 1) { u8 decipher_text[16] = {0}; rijndaelDecrypt_Final(decpt_rk, decipher_text, rank); //putchar('\n'); /* for (i = 0; i < 16; i++) { printf("0x%02x, ", decipher_text[i]); } putchar('\n'); */ } else rijndaelDecrypt_Middle(decpt_rk, rank); if(n%5 == 0) { MPI_Barrier(MPI_COMM_WORLD); } } #ifdef DUMP if(rank == n_ranks -1) { m5_dump_stats(0, 0); m5_reset_stats(0, 0); } #endif MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int rank; int n_ranks, start_rank; int i,j; float gamma = 0.25, rho = -0.495266; float GLOB_SUM = 0, sum = 0; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &n_ranks); MPI_Comm_rank(MPI_COMM_WORLD, &rank); printf("before get data in id %d\n", rank); get_data(rank%4); start_rank = 6; n_ranks = 4; printf("done getting dat rank %d\n", rank); MPI_Barrier(MPI_COMM_WORLD); // printf("crossing bar1 %d\n", rank); for (j = 0; j < INPUT_SIZE; ++j) { get_input(rank, start_rank, n_ranks); sum = compute_svm_sum(rank%4, gamma); if(rank == start_rank) { float tempBuff; GLOB_SUM = sum; for (i = start_rank+1; i < start_rank + n_ranks; ++i) { MPI_Recv(&tempBuff, 1, MPI_FLOAT, i, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); GLOB_SUM = GLOB_SUM + tempBuff; } GLOB_SUM -= rho; } else { MPI_Send((float*)&sum, 1, MPI_FLOAT, start_rank, 0, MPI_COMM_WORLD); } } //if(rank != 6) //printf("before bar2 %d\n", rank); MPI_Barrier(MPI_COMM_WORLD); if(rank == 6) { #ifdef DUMP m5_dump_stats(0, 0); m5_reset_stats(0, 0); #endif } //printf("done with thread %d\n", rank); if(rank == 6) printf("global sum = %f\n", GLOB_SUM); // free_data(); MPI_Finalize(); return 0; }