Commit 18c35280 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Choose another way to parametrize the opencl source file

parent 090158ca
......@@ -43,7 +43,7 @@ template <class OctreeClass, class CellContainerClass, class CellClass, class Ke
class CudaKernelClass = FCudaEmptyKernel<>
#endif
#ifdef ScalFMM_ENABLE_OPENCL_KERNEL
, class OpenCLDeviceWrapperClass = FOpenCLDeviceWrapper<KernelClass, nullptr>
, class OpenCLDeviceWrapperClass = FOpenCLDeviceWrapper<KernelClass>
#endif
>
class FGroupTaskStarPUAlgorithm {
......
......@@ -16,7 +16,13 @@
#include <starpu.h>
template <class OriginalKernelClass, const char* KernelFilename>
struct FEmptyOpenCLFilename{
operator const char*(){
return nullptr;
}
};
template <class OriginalKernelClass, class KernelFilenameClass = FEmptyOpenCLFilename>
class FOpenCLDeviceWrapper {
protected:
static void SetKernelArgs(cl_kernel& kernel, const int pos){
......@@ -69,10 +75,12 @@ public:
workerId = starpu_worker_get_id();
workerDevid = starpu_worker_get_devid(workerId);
if(KernelFilename){
KernelFilenameClass kernelFilename;
const char* filename = kernelFilename;
if(filename){
starpu_opencl_get_context (workerDevid, &context);
const int err = starpu_opencl_load_opencl_from_file(KernelFilename, &opencl_code, NULL);
const int err = starpu_opencl_load_opencl_from_file(filename, &opencl_code, NULL);
if(err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
FAssertLF( starpu_opencl_load_kernel(&kernel_bottomPassPerform, &queue_bottomPassPerform, &opencl_code, "bottomPassPerform", workerDevid) == CL_SUCCESS);
......@@ -97,7 +105,9 @@ public:
virtual ~FOpenCLDeviceWrapper(){
// Release
releaseKernel();
if(KernelFilename){
KernelFilenameClass kernelFilename;
const char* filename = kernelFilename;
if(filename){
const int err = starpu_opencl_unload_opencl(&opencl_code);
if(err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
}
......
......@@ -47,6 +47,13 @@ int main(int argc, char* argv[]){
FParameterDefinitions::OctreeHeight, FParameterDefinitions::NbThreads,
FParameterDefinitions::NbParticles, LocalOptionBlocSize);
// Initialize the types
struct OpenCLSource{
operator const char*(){
return "../../Src/GroupTree/OpenCl/FEmptyKernel.cl";
}
};
typedef FTestCell GroupCellClass;
typedef FGroupTestParticleContainer GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 2, long long int> GroupOctreeClass;
......@@ -55,7 +62,7 @@ int main(int argc, char* argv[]){
#ifdef ScalFMM_ENABLE_CUDA_KERNEL
, FCudaGroupOfCells<0>, FCudaGroupOfParticles<0, int>, FCudaGroupAttachedLeaf<0, int>, FCudaEmptyKernel<>
#endif
, FOpenCLDeviceWrapper<GroupKernelClass, nullptr>
, FOpenCLDeviceWrapper<GroupKernelClass, OpenCLSource>
> GroupAlgorithm;
typedef FTestCell CellClass;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment