void MainWindow::readIncomingData() { QDataStream in(tcpSocket); in.setVersion(QDataStream::Qt_4_2); if (client_number == 0) { if (tcpSocket->bytesAvailable() < (int)sizeof(quint32)) return; in >> client_number; } if (num_entries == 0) { if (tcpSocket->bytesAvailable() < (int)sizeof(quint64)) return; in >> num_entries; progress_dialog->setMaximum(num_entries); } if (blocksize == 0) { if (tcpSocket->bytesAvailable() < (int)sizeof(quint64)) return; in >> blocksize; } if ((quint64)tcpSocket->bytesAvailable() < blocksize) return; if (!test_loaded) { current_entry++; progress_dialog->setValue(current_entry); } QString received_string; QString buffer; do { in >> buffer; received_string.append(buffer); } while (!in.atEnd()); blocksize = 0; if (!test_loaded) { received_data.append(received_string); if (current_entry >= num_entries) { loadTest(received_data); test_loaded = true; } else { QByteArray ba; QDataStream out(&ba, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_2); out << current_entry; tcpSocket->write(ba); } } else { readResults(received_string); } }
int ReceiveThread::run() { ISocket * socket = ISocket::create(3456); ISocket * client = socket->accept(); StringBuffer result; readResults(client, parallelBlocked, false, result, nullptr, 0); client->Release(); socket->Release(); finishedReading.signal(); return 0; }
static CALresult checkpointCAL(SeparationCALMem* cm, const IntegralArea* ia, EvaluationState* es) { CALresult err; readResults(cm, ia, es); err = writeCheckpoint(es) ? CAL_RESULT_ERROR : CAL_RESULT_OK; #if BOINC_APPLICATION boinc_checkpoint_completed(); #endif return err; }
SwiftReader::SwiftReader(QString filename) : lineParser( SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP SEPARATOR DECIMAL_FIELD_REXP) { if(filename.length() > 0) { QFile file(filename); if (file.open(QFile::ReadOnly | QFile::Text)) { QTextStream stream(&file); readResults(stream); file.close(); } } }
static CALresult runIntegral(const AstronomyParameters* ap, const IntegralArea* ia, EvaluationState* es, const CLRequest* clr, MWCALInfo* ci, SeparationCALMem* cm) { CALresult err; SeparationCALNames cn; double t1, t2, dt, tAcc = 0.0; SeparationCALChunks chunks; memset(&cn, 0, sizeof(SeparationCALNames)); err = getModuleNames(ci, &cn, cm->numberStreams); if (err != CAL_RESULT_OK) { cal_warn("Failed to get module names", err); return err; } err = setKernelArguments(ci, cm, &cn); if (err != CAL_RESULT_OK) { destroyModuleNames(&cn); return err; } if (findCALChunks(ap, ci, clr, ia, &chunks) != CAL_RESULT_OK) return CAL_RESULT_ERROR; for (; es->nu_step < ia->nu_steps; es->nu_step++) { if (clr->enableCheckpointing && timeToCheckpointGPU(es, ia)) { err = checkpointCAL(cm, ia, es); if (err != CAL_RESULT_OK) break; } t1 = mwGetTimeMilli(); err = runNuStep(ci, cm, ia, &chunks, clr->pollingMode, es->nu_step); if (err != CAL_RESULT_OK) break; t2 = mwGetTimeMilli(); dt = t2 - t1; tAcc += dt; reportProgress(ap, ia, es, es->nu_step + 1, dt); } es->nu_step = 0; warn("Integration time = %f s, average per iteration = %f ms\n", 1.0e-3 * tAcc, tAcc / ia->nu_steps); destroyModuleNames(&cn); freeCALChunks(&chunks); if (err == CAL_RESULT_OK) { readResults(cm, ia, es); addTmpSums(es); /* Add final episode to running totals */ } return err; }
/** Run the OpenCL kernel */ short runOpenCL(struct benchmark *bench) { short j; #ifdef DEBUG printf("TEST OPENCL\n"); #endif /********************** Initializations **********************/ error=clGetPlatformIDs(1,&platform,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Error to get platform ID : %d\n",error); goto error; } error=clGetDeviceIDs(platform,CL_DEVICE_TYPE_GPU,1,&device,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Error to get device ID : %d\n",error); goto error; } if (error != CL_SUCCESS) { fprintf(stderr,"Can't get device info : %d\n",error); goto error; } context = clCreateContext(0,1,&device,NULL,NULL,&error); if (error != CL_SUCCESS) { fprintf(stderr,"Error to create context : %d\n",error); goto error; } size_t maxWorkItemDim; size_t maxWorkGroupSize; size_t workItemSize[10]; error = clGetDeviceInfo(device,CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,sizeof(size_t),&maxWorkItemDim,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Can't get max work item dimensions : %d\n",error); goto errorContext; } error = clGetDeviceInfo(device,CL_DEVICE_MAX_WORK_ITEM_SIZES,maxWorkItemDim*sizeof(size_t),workItemSize,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Can't get mwork item sizes : %d\n",error); goto errorContext; } error = clGetDeviceInfo(device,CL_DEVICE_MAX_WORK_GROUP_SIZE,sizeof(size_t),&maxWorkGroupSize,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Can't get max work item dimensions : %d\n",error); goto errorContext; } queue = clCreateCommandQueue(context, device, CL_QUEUE_PROFILING_ENABLE ,&error); if (error != CL_SUCCESS) { fprintf(stderr,"Error to create command queue : %d\n",error); goto errorContext; } /********************** Memory allocations **********************/ long i; #ifdef DEBUG printf("Create buffers\n"); #endif double createBufTime; createBufTime = createBuffers(context,bench); /********************** OpenCL kernel **********************/ cl_program program; char *fileContent; FILE *f; struct stat fState; char path[256]; strcpy(path,"Kernels/"); strcat(path,bench->kernel); stat(path,&fState); f=fopen(path,"r"); fileContent=malloc(fState.st_size*sizeof(char)); fread(fileContent,sizeof(char),fState.st_size,f); fclose(f); program=clCreateProgramWithSource(context,1,(const char**)&fileContent,&fState.st_size,&error); free(fileContent); if (error != CL_SUCCESS) { fprintf(stderr,"Can't create program : %d\n",error); goto errorBuffer; } /*error=clBuildProgram(program,1,&device,"-cl-fast-relaxed-math",NULL,NULL);*/ error=clBuildProgram(program,1,&device,"",NULL,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Can't build program : %d\n",error); goto errorProgram; } cl_kernel kernel=clCreateKernel(program,"mainKernel",&error); if (error != CL_SUCCESS) { fprintf(stderr,"Can't create kernel : %d\n",error); goto errorProgram; } /********************** Launching the kernel **********************/ #ifdef DEBUG printf("Set args\n"); #endif setArgs(kernel,bench); cl_ulong lStart; cl_ulong lEnd; double fTimeInSeconds; double fFLOPS; #ifdef DEBUG printf("Compute\n"); printf("%d\n",bench->worksizeDim); for(i=0;i<bench->worksizeDim;i++) { printf(" GLOBAL -> %d\n",bench->global_ws[i]); printf(" LOCAL -> %d\n",bench->local_ws[i]); } #endif double writeBufTime; writeBufTime=writeInputs(queue,bench); double computeTime=getCurrentTime(); error=clEnqueueNDRangeKernel(queue, kernel,bench->worksizeDim, NULL,bench->global_ws, bench->local_ws,0,NULL,&event); if (error != CL_SUCCESS) { fprintf(stderr,"Can't enqueue kernel : %d\n",error); goto errorKernel; } clFinish(queue); computeTime= getCurrentTime() - computeTime; #ifdef DEBUG printf("Read results\n"); #endif double readBufTime; readBufTime=readResults(queue,bench); error = clGetEventProfilingInfo(event,CL_PROFILING_COMMAND_START,sizeof(cl_ulong),&lStart,NULL); error |= clGetEventProfilingInfo(event,CL_PROFILING_COMMAND_END ,sizeof(cl_ulong),&lEnd,NULL); if (error != CL_SUCCESS) { fprintf(stderr,"Can't get profiling info : %d\n",error); goto errorEvent; } fTimeInSeconds = ((double)(lEnd-lStart)) / 1000000000.0; /* Send timing */ write(newsockfd,"t\n",2*sizeof(char)); sprintf(result,"%f\n",createBufTime); write(newsockfd,result,strlen(result)); sprintf(result,"%f\n",writeBufTime); write(newsockfd,result,strlen(result)); sprintf(result,"%f\n",fTimeInSeconds); write(newsockfd,result,strlen(result)); sprintf(result,"%f\n",readBufTime); write(newsockfd,result,strlen(result)); /*sprintf(result,"%f\n",computeTime); write(newsockfd,result,strlen(result)); */ /* Send results */ sendResults(bench); errorEvent: clReleaseEvent(event); errorKernel: clReleaseKernel(kernel); /********************** Cleanup **********************/ errorProgram: clReleaseProgram(program); errorBuffer: clReleaseCommandQueue(queue); releaseBuffers(bench); errorContext: clReleaseContext(context); /** HORRIBLE error processing. It may create memory leaks. It will have to be improved. */ error: return (error != CL_SUCCESS); }
std::list<VersionedValue> * VoldemortNativeRequestFormat::readGetResponse(std::istream* inputStream) { checkException(inputStream); return readResults(inputStream); }