int main(int argc, char* argv[]) { // struct config information; double sum,b1,b2; int i,j,k,temp; sum=b1=b2=0.0; //set information about cpus and nodes explicity or MAi retrieves from numarch module mai_init(argv[1]); //allocation data tab = mai_alloc_3D(X,Y,Z,sizeof(double),DOUBLE); mai_skew_mapp(tab); #pragma omp parallel for default(shared) private(j,k) for(i=0;i<X;i++) for(j=0;j<Y;j++) for(k=0;k<Z;k++) tab[i][j][k]=1.0; //--------------------------------------------------begin of computation for(temp=0;temp<TEMP;temp++) { #pragma omp parallel for default(shared) private(j,k) firstprivate(sum,b1,b2) for(i=X-1;i>=0;i--) for(j=Y-1;j>=0;j--) for(k=Z-1;k>=0;k--) { sum = tab[i][j][k]* 2.0; tab[i][j][k]= sum * 2.0; sum++; b2=sum; b1 += tab[i][j][k]; } #pragma omp parallel for default(shared) private(j,k) firstprivate(sum,b1,b2) for(i=1;i<X;i++) for(j=1;j<Y;j++) for(k=0;k<Z-1;k++) { sum = tab[i-1][j-1][k]* 2.0; tab[i][j][k]= sum * 2.0; sum++; b2=sum; b1 += tab[i][j][k+1]; } } //----------------------------------------------------------------------- mai_final(); return 0; }
uint32_t fe_vieo_init(uint8_t *logName) { uint32_t rc = SUCCESS; static const char func[] = "fe_vieo_init"; IB_ENTER(func, 0, 0, 0, 0); fd_dm = INVALID_HANDLE; fdsa = INVALID_HANDLE; // initialize MAI subsystem mai_set_num_end_ports( MIN(fe_config.subnet_size, MAI_MAX_QUEUED_DEFAULT) ); mai_init(); IB_LOG_INFO("Device = ", fe_config.hca); rc = if3_register_fe(fe_config.hca,fe_config.port,(void *)FE_SERVICE_NAME,FE_SERVICE_ID, IF3_REGFORCE_PORT,&fdsa); if (rc != VSTATUS_OK) { if (fe_config.debug) IB_LOG_INFINI_INFORC("Failed to register with IF3, will try later. rc:", rc); } else { rc = fe_if3_subscribe_sa(); if (rc != VSTATUS_OK) { IB_LOG_ERRORRC("Failed to subscribe for traps in SA rc:", rc); } // connect to Performance Manager if (pm_lid) rc = if3_lid_mngr_cnx(fe_config.hca,fe_config.port,MAD_CV_VFI_PM,pm_lid,&fd_pm); else rc = if3_sid_mngr_cnx(fe_config.hca,fe_config.port,(void *)PM_SERVICE_NAME,PM_SERVICE_ID, MAD_CV_VFI_PM,&fd_pm); if (rc != VSTATUS_OK) { IB_LOG_INFINI_INFORC("Failed to open Performance Manager, will try later. rc:", rc); fd_pm = INVALID_HANDLE; } #ifdef DEVICE_MANAGER // not implemented yet // connect to Device Manager if (dm_lid) rc = if3_lid_mngr_cnx(fe_config.hca,fe_config.port,DM_IF3_MCLASS,dm_lid,&fd_dm); else rc = if3_sid_mngr_cnx(fe_config.hca,fe_config.port,DM_SERVICE_NAME,DM_SERVICE_ID, DM_IF3_MCLASS,&fd_dm); if (rc != VSTATUS_OK) { IB_LOG_INFINI_INFORC("Failed to open Device Manager, wil try later. rc:", rc); fd_dm = INVALID_HANDLE; } #endif } IB_EXIT(func, 0); return(rc); }
int main(int argc, char *argv[]) { IBhandle_t fd; uint32_t slid; uint32_t dlid; Mai_t out_mai; Status_t status; // // Get the slid and dlid. // if (argc != 3) { fprintf(stderr, "send <slid> <dlid>\n"); exit(1); } slid = strtoul(argv[1], NULL, 0); dlid = strtoul(argv[2], NULL, 0); // // Open my log file. // //vs_log_open("/tmp/send.log", 0); // // Initialize the MAI subsystem and open the port. // mai_init(); status = mai_open(0, 0, 5, &fd); if (status != VSTATUS_OK) { fprintf(stderr, "Can't open MAI (%d)\n", status); exit(0); } // // Setup the data for a MAD. // Mai_Init(&out_mai); AddrInfo_Init(&out_mai, slid, dlid, SMI_MAD_SL, STL_DEFAULT_FM_PKEY, MAI_SMI_QP, MAI_SMI_QP, 0x0); LRMad_Init(&out_mai, MAD_CV_SUBN_LR, MAD_CM_SEND, 0x0102030405060708ull, 0x10, 0x0, 0x0); // // Send the request. // status = mai_send(fd, &out_mai); if (status != VSTATUS_OK) { fprintf(stderr, "Can't send a MAD (%d)\n", status); mai_close(fd); exit(1); } mai_close(fd); exit(0); }
int main(int argc, char *argv[]) { int i, j; double tmp=0,tma=0; /* read command line and initialize grids */ if (argc < 2) { printf("jacobi size n_iter\n"); exit(0); } gridSize = atoi(argv[1]); numIters = atoi(argv[3]); #ifndef MAI tma=0.0; tma = myms(); grid1 = (double**)malloc((gridSize+3)*sizeof(double*)); grid2 = (double**)malloc((gridSize+3)*sizeof(double*)); for(i = 0; i <= gridSize; i++) { grid1[i] = (double*)malloc((gridSize+3)*sizeof(double)); grid2[i] = (double*)malloc((gridSize+3)*sizeof(double)); } tma = myms() - tma; printf("Malloc time %f\n",tma/1.e+6); #endif #ifdef MAI mai_init(NULL); tma=0.0; tma = myms(); grid1 = mai_alloc_2D(gridSize,gridSize, sizeof(double),DOUBLE); grid2 = mai_alloc_2D(gridSize,gridSize, sizeof(double),DOUBLE); tma = myms() - tma; printf("MAi alloc time: %f\n",tma/1.e+6); #endif mai_bind_rows(grid1); mai_bind_rows(grid2); InitializeGrids(); tma=0.0; tma = myms(); jacobi(); #ifdef IRREGULAR mai_cyclic(grid1); mai_cyclic(grid2); irregular(gridSize); #endif tma = myms() - tma; printf("Execution time %f\n",tma/1.e+6); }
int main(int argc, char *argv[]) { /* thread ids and attributes */ pthread_t workerid[MAXWORKERS]; pthread_attr_t attr; int i, j; double maxdiff = 0.0; FILE *results; double tmp=0,tma=0; /* set global thread attributes */ pthread_attr_init(&attr); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); pthread_mutex_init(&barrier, NULL); pthread_cond_init(&go, NULL); if (argc < 4) { printf("jacobi size n_thread n_iter\n"); exit(0); } gridSize = atoi(argv[1]); numWorkers = atoi(argv[2]); numIters = atoi(argv[3]); stripSize = gridSize/numWorkers; mai_init(BIND); for (i = 0; i < numWorkers; i++) pthread_create(&workerid[i], &attr, Worker, (void *) i); for (i = 0; i < numWorkers; i++) pthread_join(workerid[i], NULL); for (i = 0; i < numWorkers; i++) if (maxdiff < maxDiff[i]) maxdiff = maxDiff[i]; printf("number of iterations: %d\nmaximum difference: %e\n", numIters, maxdiff); }
int main(int argc, char *argv[]) { int rc,i,q; IBhandle_t fd, fd2; uint64_t tid; if(argc > 1) parse_cmd_line(argc,argv); mai_init(); rc=ib_init_devport(&ib_dev, &ib_port, NULL); if (rc) { printf("ERROR: ib_init_devport failed, %s\n",cs_convert_status(rc)); exit(1); } IB_ENTER("otest", ib_qp, ib_dev, ib_port, 0); for(q=0;q<10;q++) { rc = mai_open(ib_qp,ib_dev,ib_port,&fd); printf("otest: open got returned status %s\n",cs_convert_status(rc)); if(rc != VSTATUS_OK) { printf("ERROR: open failed 1: %s\n",cs_convert_status(rc)); return rc; } rc = mai_open(ib_qp,ib_dev,ib_port,&fd2); printf("otest: open got returned status %s\n",cs_convert_status(rc)); if(rc != VSTATUS_OK) { printf("ERROR: open failed 2: %s\n",cs_convert_status(rc)); return rc; } for(i=0;i<3;i++) { rc=mai_alloc_tid(fd,0xff,&tid); if(rc != VSTATUS_OK) { printf("ERROR: Could not allocate TID: %s\n",cs_convert_status(rc)); } else { printf("%d: Got tid %llx\n",i,(long long unsigned int)tid); } #ifdef PAW // optional check to make sure nothing appears on Q { Mai_t mad; rc = mai_recv(fd,&mad,5000000); if(rc != VSTATUS_TIMEOUT) { printf("ERROR: otest: bad status %s\n",cs_convert_status(rc)); printf("otest: shutting down.. mai_recv status\n"); IB_EXIT("otest",rc); return rc; } } #endif } printf("otest: shutting down.. \n"); rc =mai_close(fd); rc =mai_close(fd2); sleep(4); //need by simulator.. } IB_EXIT("otest",rc); return rc; }
int main(int argc, char *argv[]) { IBhandle_t fd; Mai_t in_mai; Filter_t filter; Status_t status; uint32_t port; uint32_t dev=0; if (argc != 2) { fprintf(stderr, "usage: qp1sink <port>\n"); exit(-1); } port = strtoul(argv[1], NULL, 0); // // Initialize the MAI subsystem and open the port. // mai_init(); status=ib_init_devport(&dev, &port, NULL); if (status) { printf("ib_init_devport failed, %d\n",status); exit(1); } status = mai_open(1, 0, port, &fd); if (status != VSTATUS_OK) { fprintf(stderr, "Can't open MAI (%d)\n", status); exit(0); } // // Create the filter so we can receive the reply to our request. // Filter_Init(&filter, MAI_ACT_FMASK, MAI_TYPE_EXTERNAL); filter.value.tid = 0xF002030405060708ull; filter.mask.tid = 0xF000000000000000ull; status = mai_filter_create(fd, &filter, VFILTER_SHARE); if (status != VSTATUS_OK) { fprintf(stderr, "Can't create a filter (%d)\n", status); mai_close(fd); exit(1); } while (1) { // // Wait five second for an answer. // status = mai_recv(fd, &in_mai, 1000000); if (status != VSTATUS_OK) { fprintf(stderr, "Didn't receive a MAD (%d)\n", status); continue; } // // Display the MAD that came in. // dumpit(&in_mai); } // // Delete the filter. // status = mai_filter_delete(fd, &filter, VFILTER_SHARE); if (status != VSTATUS_OK) { fprintf(stderr, "Can't delete a filter (%d)\n", status); mai_close(fd); exit(1); } mai_close(fd); exit(0); }
int main(int argc, char *argv[]) { int i,rc; Filter_t *fh; int max; if(argc > 1) parse_cmd_line(argc,argv); srand(getpid()); mai_init(); rc=ib_init_devport(&ib_dev, &ib_port, NULL); if (rc) { printf("ERROR: ib_init_devport failed, %s\n",cs_convert_status(rc)); exit(1); } for(i=0;i<fdcount;i++) { if ((rc = mai_open(0, ib_dev, ib_port, &fd[i])) != VSTATUS_OK) { printf("ERROR: can't open mai %s\n", cs_convert_status(rc)); exit(1); } } printf("\nINFO: PRE-TEST layers charecteristics %d\n",0); mode = fmode; switch(mode) { case FILTER_EXPOSED: printf("********** EXPOSED FILTER MODE *************\n"); break; case FILTER_METHOD: printf("********** METHOD MODE *********************\n"); break; case FILTER_AID: printf("********** AID MODE ************************\n"); break; case FILTER_AMOD: printf("********** AMOD MODE ************************\n"); break; case FILTER_ONCE: printf("********** ONCE MODE not supported *************************\n"); exit(-1); break; default: printf("********** UNKOWN MODE ***********************\n"); exit(-1); break; } memset(&all_filter,0,sizeof(all_filter)); max = fdcount; fh = &all_filter[0]; //First we linearly create the filters and delete them in the order //they were created. if(readers) { for(i=0;i<max;i++) { char name[32]; switch(mode) { case FILTER_EXPOSED: { IBhandle_t hd; fh->dev = ib_dev; fh->qp = MAI_FILTER_ANY; fh->port= ib_port; fh->type = MAI_TYPE_ANY; fh->value.bversion = i%2; fh->value.mclass = i%256; fh->value.cversion = i%256; fh->value.method = i%256; fh->value.status = i%(1<<16); fh->value.hopPointer = i%64; fh->value.hopCount = i%64; fh->value.tid = i; fh->value.aid = i%(1<<16); fh->value.amod = i; fh->mask.bversion = MAI_FMASK_ALL; fh->mask.mclass = MAI_FMASK_ALL; fh->mask.cversion = MAI_FMASK_ALL; fh->mask.method = MAI_FMASK_ALL; fh->mask.status = MAI_FMASK_ALL; fh->mask.hopPointer = MAI_FMASK_ALL; fh->mask.hopCount = MAI_FMASK_ALL; fh->mask.tid = MAI_FMASK_ALL; fh->mask.aid = MAI_FMASK_ALL; fh->mask.amod = MAI_FMASK_ALL; fh->active = (MAI_ACT_QP | MAI_ACT_DEV | MAI_ACT_TYPE | MAI_ACT_PORT | MAI_ACT_FMASK); sprintf(name,"Fil %d",i); MAI_SET_FILTER_NAME(fh,name); //now create the filter rc = mai_filter_hcreate(fd[i%fdcount],fh,flags,&all_handles[i]); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_create return status\n",cs_convert_status(rc)); exit(-1); } //now get the handle and compare .. make sure they //point to the same thing. rc = mai_filter_handle(fd[i%fdcount],fh,flags,&hd); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to get filter handle\n",i); printf("ERROR: %s - mai_filter_handle return status\n",cs_convert_status(rc)); exit(-1); } if(hd != all_handles[i]) { printf("ERROR: %d - Filter handles do not agree\n",i); exit(-1); } fh++; } break; case FILTER_METHOD: { rc = mai_filter_method(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_method return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_AID: { rc = mai_filter_aid(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_aid return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_AMOD: { rc = mai_filter_amod(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i%256,i,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_amod return status\n",cs_convert_status(rc)); exit(-1); } } break; case FILTER_ONCE: { rc = mai_filter_once(fd[i%fdcount],flags,MAI_TYPE_INTERNAL,&all_handles[i],i/256,i); if(rc != VSTATUS_OK) { printf("ERROR: %d - Unable to create filter\n",i); printf("ERROR: %s - mai_filter_method return status\n",cs_convert_status(rc)); exit(-1); } } break; default: { printf("ERROR: %d - Unknown filter test mode\n",mode); exit(-1); } } } } if(writer) { //start the writer thread if(readers==0) { i=Writer(); shutdown_test(i); } else { //start the workert thread rc = vs_thread_create(&thandle[thread_cnt], (unsigned char*)"Writer",//name (void (*) (uint32_t,uint8_t**)) Writer, //func 0, //argc NULL, //argptr STACK_SIZE //stacksize ); if(rc) { printf("ERROR (%s): creating Writer thread\n", cs_convert_status(rc)); exit(-1); } printf("\nINFO: Writer thread created %s\n",cs_convert_status(rc)); thread_cnt++; } } if(readers) { int threads=0; int idx; if(fdcount > 2) { int threads; //start 2 normal readers and then //a wait_handle reader if(fdcount == 3) { threads = 1; idx = 2; } else { threads = 2; idx = fdcount - 2; } //now start single handle readers for(i=0;i<threads;i++) { thread_argv[thread_cnt][0] = (uint8_t*)(unsigned long)idx++; thread_argv[thread_cnt][1] = (uint8_t*)(unsigned long)1; rc = vs_thread_create(&thandle[thread_cnt], (unsigned char*)"Reader",//name (void (*) (uint32_t,uint8_t**))ThreadStart, //func 2, //argc (uint8_t **)&thread_argv[thread_cnt], //argptr STACK_SIZE //stacksize ); if(rc) { printf("ERROR (%s): creating reader thread\n", cs_convert_status(rc)); return -1; } thread_cnt++; } } //now do multi handle recv Reader(0,fdcount-threads); while(threads); } shutdown_test(mads-loop); return 0; }
int main() { int quantum, checktick(); int BytesPerWord; register int j, k; double scalar, t, times[4][NTIMES]; #ifdef MAI mai_init(NULL); a = mai_alloc_1D(N, sizeof(double),DOUBLE); b = mai_alloc_1D(N, sizeof(double),DOUBLE); c = mai_alloc_1D(N, sizeof(double),DOUBLE); mai_bind_columns(a); mai_bind_columns(b); mai_bind_columns(c); #else a = malloc(N*sizeof(double)); b = malloc(N*sizeof(double)); c = malloc(N*sizeof(double)); #endif /* --- SETUP --- determine precision and check timing --- */ printf(HLINE); printf("STREAM version $Revision: 5.9 $\n"); printf(HLINE); BytesPerWord = sizeof(double); printf("This system uses %d bytes per DOUBLE PRECISION word.\n", BytesPerWord); printf(HLINE); printf("Total memory required = %.1f MB.\n", (3.0 * BytesPerWord) * ( (double) N / 1048576.0)); printf("Each test is run %d times, but only\n", NTIMES); printf("the *best* time for each is used.\n"); #ifdef _OPENMP printf(HLINE); #pragma omp parallel { #pragma omp master { k = omp_get_num_threads(); printf ("Number of Threads requested = %i\n",k); } } #endif /* Get initial value for system clock. */ #pragma omp parallel for for (j=0; j<N; j++) { a[j] = 1.0; b[j] = 2.0; c[j] = 0.0; } printf(HLINE); #ifdef MAI mai_cyclic(a); mai_cyclic(b); mai_cyclic(c); #endif int chunk = 128; t = mysecond(); #pragma omp parallel for schedule(dynamic,chunk) for (j = 0; j < N; j++) a[j] = 2.0E0 * a[j]; t = 1.0E6 * (mysecond() - t); /* --- MAIN LOOP --- repeat test cases NTIMES times --- */ scalar = 3.0; for (k=0; k<NTIMES; k++) { times[0][k] = mysecond(); #ifdef TUNED tuned_STREAM_Copy(); #else #pragma omp parallel for schedule(dynamic,chunk) for (j=0; j<N; j++) c[j] = a[j]; #endif times[0][k] = mysecond() - times[0][k]; times[1][k] = mysecond(); #ifdef TUNED tuned_STREAM_Scale(scalar); #else #pragma omp parallel for schedule(dynamic,chunk) for (j=0; j<N; j++) b[j] = scalar*c[j]; #endif times[1][k] = mysecond() - times[1][k]; times[2][k] = mysecond(); #ifdef TUNED tuned_STREAM_Add(); #else #pragma omp parallel for schedule(dynamic,chunk) for (j=0; j<N; j++) c[j] = a[j]+b[j]; #endif times[2][k] = mysecond() - times[2][k]; times[3][k] = mysecond(); #ifdef TUNED tuned_STREAM_Triad(scalar); #else #pragma omp parallel for schedule(dynamic,chunk) for (j=0; j<N; j++) a[j] = b[j]+scalar*c[j]; #endif times[3][k] = mysecond() - times[3][k]; } /* --- SUMMARY --- */ for (k=1; k<NTIMES; k++) /* note -- skip first iteration */ { for (j=0; j<4; j++) { avgtime[j] = avgtime[j] + times[j][k]; mintime[j] = MIN(mintime[j], times[j][k]); maxtime[j] = MAX(maxtime[j], times[j][k]); } } printf("Function Rate (MB/s) Avg time Min time Max time\n"); for (j=0; j<4; j++) { avgtime[j] = avgtime[j]/(double)(NTIMES-1); printf("%s%11.4f %11.4f %11.4f %11.4f\n", label[j], 1.0E-06 * bytes[j]/mintime[j], avgtime[j], mintime[j], maxtime[j]); } printf(HLINE); /* --- Check Results --- */ checkSTREAMresults(); printf(HLINE); return 0; }
int main(int argc, char* argv[]) { // struct config information; double TimeI,TimeF,TII,TIF,TI; double sum,b1,b2; int i,j,k,temp; char msg[215]; sum=b1=b2=0.0; /* initialize memon */ init_memon(); mai_init(argv[1]); tab = mai_alloc_3D(X,Y,Z,sizeof(double),DOUBLE); mai_skew_mapp(tab); /* attach memory to memtop */ sprintf(msg,"array 3D"); attach_memory(tid(),msg,tab[0][0],X*Y*Z*sizeof(double)); #pragma omp parallel for default(shared) private(j,k) for(i=0;i<X;i++) for(j=0;j<Y;j++) for(k=0;k<Z;k++) tab[i][j][k]=0.0; //------------------------------------------------------------------- //--------------------------------------------------begin of computation for(temp=0;temp<TEMP;temp++) { #pragma omp parallel for default(shared) private(j,k) firstprivate(sum,b1,b2) for(i=0;i<X;i++) for(j=0;j<Y;j++) for(k=0;k<Z;k++) { sum = tab[i][j][k]* 2.0; tab[i][j][k]= sum * 2.0; sum++; b2=sum; b1 += tab[i][j][k]; } #pragma omp parallel for default(shared) private(j,k) firstprivate(sum,b1,b2) for(i=0;i<X;i++) for(j=0;j<Y;j++) for(k=0;k<Z;k++) { sum = tab[i][j][k]* 2.0; tab[i][j][k]= sum * 2.0; sum++; b2=sum; b1 += tab[i][j][k]; } } //----------------------------------------------------------------------- mai_final(); detach_memory(tid(),msg,tab[0][0]); /* finalize memon */ finalize_memon(); return 0; }
int main(int argc, char* argv[]) { int rc,i; uint64_t tid; IBhandle_t fd = -1,fh; Mai_t mad, rmad; uint8_t name[16]; /* Parse command line arguments */ if (argc > 1) parse_cmd_line(argc,argv); /* Initialize MAD */ memset(&rmad,0,sizeof(rmad)); /* Initialize MAD */ memset(&mad,0,sizeof(mad)); /* Initialize MAI subsystem */ mai_init(); rc=ib_init_devport(&ib_dev, &ib_port, NULL); if (rc) { printf("ib_init_devport failed, %d\n",rc); return rc; } /* Create MAI handle to used to communicate */ rc = mai_open(MAI_GSI_QP,ib_dev,ib_port,&fd); if (rc) { printf("MAI_OPEN failed, %d\n",rc); return rc; } /* Initialize MAD that will be sent */ if(oob) mad.type = MAI_TYPE_INTERNAL; else mad.type = MAI_TYPE_EXTERNAL; mad.base.method = method; mad.base.mclass = mclass; mad.base.aid = aid; AddrInfo_Init(&mad, slid, dlid, 0, STL_DEFAULT_FM_PKEY, MAI_GSI_QP, MAI_GSI_QP, GSI_WELLKNOWN_QKEY); mad.base.bversion = MAD_BVERSION; mad.base.cversion = MAD_CVERSION; mad.active = MAI_ACT_BASE | MAI_ACT_DATA | MAI_ACT_TYPE | MAI_ACT_ADDRINFO; /* Create filter to listen for response */ rc = mai_filter_method(fd,VFILTER_SHARE,MAI_TYPE_ANY, &fh, mclass, RESPONSE); if (rc) { printf("Cannot create filter to listen for responses \n"); return rc; } if(use_event) { sprintf((char *) name, "client"); rc = vs_event_create(&event, name, (Eventset_t) 0x00U); if (rc) { IB_LOG_ERRORRC("vs_event_create failed rc:", rc); return rc; } } /* Loop which sends MADS to receiver */ for (i = 0; i < loop; i++) { /* Get a transaction ID for message we are about to send */ rc = mai_alloc_tid(fd, mclass, &tid); /* Assign transaction ID to the MAD to be sent */ mad.base.tid = tid; /* Send command to receiver */ rc = mai_send(fd,&mad); if (rc) { printf("MAI send failed %d \n",rc); return rc; } printf("MAD sent\n"); printf("Waiting for acknowledgement\n"); if(use_event) { Eventset_t events = (Eventset_t) 0U; do{ rc = vs_event_wait(event.event_handle, timeout,0x1,&events); }while(rc == VSTATUS_AGAIN); if(rc == VSTATUS_OK) { rc = mai_recv(fd,&rmad,MAI_RECV_NOWAIT); } printf("Event wait returned %d\n",rc); } else { /* Get acknowledgement */ rc = mai_recv(fd,&rmad,timeout); } if (rc != VSTATUS_OK) { printf("Acknowledgement not received \n"); return rc; } printf("Acknowledgement received\n"); printf("Passed Loop %d\n ",i); //sleep(1); } /* Delete filter */ mai_filter_hdelete(fd,fh); /* Close MAI channel */ rc = mai_close(fd); if (rc) { printf("Close failed\n"); return rc; } printf("Test successful!!\n"); return rc; }
int main() { int available = numa_available(); if( available == -1 ) { printf( "NUMA is not available on this system!\n" ); return -1; } printf( "numa_available() returned %d\n", available ); mai_init(BIND); int nodes = numa_max_node(); printf( "There are %d NUMA nodes in this system:\n\n", nodes + 1 ); DumpMemoryStats(); // initialize the random number list int x; for(x = 0; x < WORKERS_COUNT * MAJOR_COUNT; x++ ) { rand_nums[x] = 6 + rand() % MAX_BLOCK_FACTOR; } time_t time_start = time(NULL); // start worker threads printf( "\nStarting workers...\n" ); int thread_no = 0,node,m; for(node = 0; node < CORES_COUNT; node++ ) { for(m = 0; m < WORKERS_PER_CORE; m++ ) { CreateWorkerThread( thread_no, node ); thread_no++; } } // wait until all threads complete printf( "Waiting for workers to complete...\n" ); int n; for( n = 0; n < WORKERS_COUNT; n++ ) { if( 0 != pthread_join( targs[n].tid, NULL ) ) { printf( "pthread_join failed!\n" ); } } time_t time_end = time(NULL); printf( "All worker threads completed!\n\n" ); DumpMemoryStats(); double seconds = difftime( time_end, time_start ); unsigned long long min = 0xffffffffffffffffll; unsigned long long max = 0; unsigned long long avg = 0; for( n = 0; n < WORKERS_COUNT; n++ ) { if( targs[n].tdiff < min ) min = targs[n].tdiff; if( targs[n].tdiff > max ) max = targs[n].tdiff; avg = avg + targs[n].tdiff; } printf( "\n%f seconds\t( avg: %llu,\tmin: %llu,\tmax: %llu ticks)\n", seconds, avg, min, max ); return 0; }