MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / compileKernels

Method compileKernels

src/library/enqueue.cpp:701–828  ·  view source on GitHub ↗

Compile the kernels that this plan uses, and store into the plan

Source from the content-addressed store, hash-verified

699
700// Compile the kernels that this plan uses, and store into the plan
701clfftStatus FFTAction::compileKernels( const cl_command_queue commQueueFFT, const clfftPlanHandle plHandle, FFTPlan* fftPlan )
702{
703 cl_int status = 0;
704 size_t deviceListSize = 0;
705
706 FFTRepo& fftRepo = FFTRepo::getInstance( );
707
708 // create a cl program executable for the device associated with command queue
709 // Get the device
710 cl_device_id &q_device = fftPlan->bakeDevice;
711
712 cl_program program;
713 if( fftRepo.getclProgram( this->getGenerator(), this->getSignatureData(), program, q_device, fftPlan->context ) == CLFFT_INVALID_PROGRAM )
714 {
715 FFTBinaryLookup lookup (this->getGenerator(), plHandle, fftPlan->context, q_device);
716
717 lookup.variantRaw(this->getSignatureData(), this->getSignatureData()->datasize);
718
719 if (lookup.found())
720 {
721#if FFT_CACHE_DEBUG
722 // debug message in debug mode to ensure that the cache is used
723 fprintf(stderr, "Kernel loaded from cache\n");
724#endif
725
726 program = lookup.getProgram();
727 }
728 else
729 {
730#if FFT_CACHE_DEBUG
731 fprintf(stderr, "Kernel built from source\n");
732#endif
733
734 // If the user wishes us to write the kernels out to disk, we do so
735 if( fftRepo.setupData.debugFlags & CLFFT_DUMP_PROGRAMS )
736 {
737 OPENCL_V( writeKernel( plHandle, this->getGenerator(), this->getSignatureData(), fftPlan->context, fftPlan->bakeDevice ), _T( "writeKernel failed." ) );
738 }
739
740 std::string programCode;
741 OPENCL_V( fftRepo.getProgramCode( this->getGenerator(), this->getSignatureData(), programCode, q_device, fftPlan->context ), _T( "fftRepo.getProgramCode failed." ) );
742
743 const char* source = programCode.c_str();
744 program = clCreateProgramWithSource( fftPlan->context, 1, &source, NULL, &status );
745 OPENCL_V( status, _T( "clCreateProgramWithSource failed." ) );
746
747 // create a cl program executable for the device associated with command queue
748
749#if defined(DEBUGGING)
750 status = clBuildProgram( program, 1, &q_device, "-g -cl-opt-disable", NULL, NULL); // good for debugging kernels
751
752// if you have trouble creating smbols that GDB can pick up to set a breakpoint after kernels are loaded into memory
753// this can be used to stop execution to allow you to set a breakpoint in a kernel after kernel symbols are in memory.
754#ifdef DEBUG_BREAK_GDB
755 __debugbreak();
756#endif
757#else
758 status = clBuildProgram( program, 1, &q_device, "", NULL, NULL);

Callers

nothing calls this directly

Calls 13

getclProgramMethod · 0.80
variantRawMethod · 0.80
foundMethod · 0.80
getProgramMethod · 0.80
getProgramCodeMethod · 0.80
setProgramMethod · 0.80
populateCacheMethod · 0.80
setclProgramMethod · 0.80
getclKernelMethod · 0.80
getProgramEntryPointMethod · 0.80
setclKernelMethod · 0.80
getGeneratorMethod · 0.45

Tested by

no test coverage detected