static CALresult runNuStep(MWCALInfo* ci, SeparationCALMem* cm, const IntegralArea* ia, const SeparationCALChunks* chunks, CALint pollingMode, CALuint nuStep) { CALdomain domain; CALuint i; CALresult err = CAL_RESULT_OK; err = setNuKernelArgs(cm, ia, nuStep); if (err != CAL_RESULT_OK) return err; domain.x = 0; domain.width = ia->r_steps; for (i = 0; i < chunks->nChunkMu && err == CAL_RESULT_OK; ++i) { domain.y = chunks->chunkMuBorders[i]; domain.height = chunks->chunkMuBorders[i + 1] - chunks->chunkMuBorders[i]; mw_begin_critical_section(); err = runKernel(ci, &domain, pollingMode, chunks->chunkWaitTime); mw_end_critical_section(); } return err; }
void printSeparationResults(const SeparationResults* results, unsigned int numberStreams) { unsigned int i; mw_begin_critical_section(); /* Print integrals */ warn("<background_integral> %.15f </background_integral>\n", results->backgroundIntegral); warn("<stream_integral> "); for (i = 0; i < numberStreams; ++i) warn(" %.15f ", results->streamIntegrals[i]); warn("</stream_integral>\n"); /* Print individual likelihoods */ warn("<background_likelihood> %.15f </background_likelihood>\n", results->backgroundLikelihood); warn("<stream_only_likelihood> "); for (i = 0; i < numberStreams; ++i) warn(" %.15f ", results->streamLikelihoods[i]); warn("</stream_only_likelihood>\n"); /* Print overall likelihood */ warn("<search_likelihood> %.15f </search_likelihood>\n", results->likelihood); mw_end_critical_section(); }
static cl_int runNuStep(CLInfo* ci, const IntegralArea* ia, const RunSizes* runSizes, cl_uint nu_step) { cl_uint i; cl_int err = CL_SUCCESS; size_t offset[1]; err = setNuKernelArgs(ia, nu_step); if (err != CL_SUCCESS) { mw_printf("Failed to set nu kernel argument\n"); return err; } mw_begin_critical_section(); offset[0] = 0; for (i = 0; i < runSizes->nChunk && err == CL_SUCCESS; ++i) { err = runIntegralKernel(ci, runSizes, offset); checkQuitRequest(); /* Kernel has finished by now */ offset[0] += runSizes->global[0]; } mw_end_critical_section(); return err; }
static void checkQuitRequest() { if (mw_status_quit_request() || mw_status_abort_request()) { mw_end_critical_section(); exit(0); } }
static cl_int readKernelResults(CLInfo* ci, SeparationCLMem* cm, EvaluationState* es, const IntegralArea* ia) { cl_int err = CL_SUCCESS; cl_int i; mw_begin_critical_section(); err = runSummarization(ci, cm, ia, 0, &es->bgSumCheckpoint); checkQuitRequest(); for (i = 0; err == CL_SUCCESS && i < es->numberStreams; ++i) { err = runSummarization(ci, cm, ia, i + 1, &es->streamSumsCheckpoint[i]); checkQuitRequest(); } mw_end_critical_section(); return err; }
void printSeparationResults(const SeparationResults* results, unsigned int numberStreams, int LikelihoodToText) { unsigned int i; mw_begin_critical_section(); fflush(stdout); /* Print integrals */ mw_printf("<background_integral> %.15f </background_integral>\n", results->backgroundIntegral); mw_printf("<stream_integral> "); for (i = 0; i < numberStreams; ++i) mw_printf(" %.15f ", results->streamIntegrals[i]); mw_printf("</stream_integral>\n"); /* Print individual likelihoods */ mw_printf("<background_likelihood> %.15f </background_likelihood>\n", results->backgroundLikelihood); mw_printf("<stream_only_likelihood> "); for (i = 0; i < numberStreams; ++i) mw_printf(" %.15f ", results->streamLikelihoods[i]); mw_printf("</stream_only_likelihood>\n"); /* Print overall likelihood */ mw_printf("<search_likelihood> %.15f </search_likelihood>\n", results->likelihood); if (LikelihoodToText) { FILE * pFile; pFile = fopen ("results.txt","w"); fprintf (pFile, "%.15f",results->likelihood); fclose (pFile); } fflush(stderr); mw_end_critical_section(); }