#include #include #include #include #include #include #ifdef XCPU #include #include #endif using namespace std; namespace xppc{ #ifdef XLIB struct begin{ begin(){ cerr<0?prop.multiProcessorCount:WNUM; pmax=nblk*NTHR*NPHO; } { pn=0; e.type=type; e.hidx=0; for(int m=0; m<3; m++) e.r[m]=0; } { unsigned int size=d.rsize; if(size>>(ed, num); checkError(cudaGetLastError()); checkError(cudaEventRecord(evt2, NULL)); checkError(cudaEventSynchronize(evt2)); checkError(cudaEventElapsedTime(&dt, evt1, evt2)); deviceTime+=dt; checkError(cudaEventDestroy(evt1)); checkError(cudaEventDestroy(evt2)); checkError(cudaThreadSynchronize()); } { checkError(cudaMemcpy(&e, ed, sizeof(int), cudaMemcpyDeviceToHost)); unsigned int size=e.hidx*sizeof(hit); checkError(cudaMemcpy(d.hits, e.hits, size, cudaMemcpyDeviceToHost)); } #endif cerr<<"photons: "<=e.hnum) cerr<<"Error: data buffer overflow occurred!"<0; i-=pmax){ if(i0) printf("\n"); } fin(); } void output(){ #ifdef XCPU e.hidx=0; #else { e.hidx=0; checkError(cudaMemcpy(ed, &e, sizeof(int), cudaMemcpyHostToDevice)); } { unsigned int size=pn*sizeof(photon); checkError(cudaMemcpy(e.pz, pz, size, cudaMemcpyHostToDevice)); } #endif kernel(pn*OVER); pn=0; } #ifdef XCPU void start(){} void stop(){} void choose(int device){ #ifdef MKOW srand(device); #endif seed=device; } void listDevices(){} #else void start(){ cudaSetDeviceFlags(cudaDeviceBlockingSync); } void stop(){ fprintf(stderr, "\nDevice time: %2.1f [ms]\n", deviceTime); checkError(cudaThreadExit()); } void choose(int device){ #ifdef MKOW srand(device); #endif checkError(cudaSetDevice(device)); checkError(cudaGetDeviceProperties(&prop, device)); } #endif } #ifndef XLIB using namespace xppc; int main(int arg_c, char *arg_a[]){ start(); if(arg_c<=1){ listDevices(); fprintf(stderr, "\nUse: %s [device] (f2k muons)\n" " %s [str] [om] [num] [device] (flasher)\n", arg_a[0], arg_a[0]); } else if(0==strcmp(arg_a[1], "-")){ ices * w = d.w[d.nfla]; cerr<<"For wv slice "<<(d.nfla+1)<<"/"<z[i].abs<<" "<z[i].sca<1) device=atoi(arg_a[1]); choose(device); fprintf(stderr, "Processing f2k muons from stdin on device %d\n", device); f2k(); } else{ int str=0, dom=0, device=0, itr=0; unsigned long long num=1000000ULL; if(arg_c>1) str=atoi(arg_a[1]); if(arg_c>2) dom=atoi(arg_a[2]); if(arg_c>3){ num=(unsigned long long) atof(arg_a[3]); char * sub = strchr(arg_a[3], '*'); if(sub!=NULL) itr=(int) atof(++sub); } if(arg_c>4) device=atoi(arg_a[4]); choose(device); fprintf(stderr, "Running flasher simulation on device %d\n", device); flasher(str, dom, EFF*MAS*num, itr); } stop(); } #endif