Pārlūkot izejas kodu

making opencl dependency optional

Nicolas Winkler 4 gadi atpakaļ
vecāks
revīzija
c06409c6c2

+ 4 - 3
libmandel/CMakeLists.txt

@@ -11,6 +11,7 @@ else()
 endif()
 option(MANDEL_AVX512 "generate code that can make use of avx-512-instructions" ON)
 option(MANDEL_ASMJIT "use just-in-time-compilation library asmjit" ON)
+option(MANDEL_OPENCL "use opencl to offload calculations on GPU devices" ON)
 option(MANDEL_BUILD_NATIVE
 	"use the -march=native flags if supported WARNING: when compiling with this flag, the binary might not run on machines other than the one it was compiled on"
 	OFF)
@@ -92,14 +93,14 @@ if(MANDEL_ASMJIT)
 endif(MANDEL_ASMJIT)
 
 
-if(OPENCL_FOUND)
+if(OPENCL_FOUND AND MANDEL_OPENCL)
     target_compile_definitions(mandel PUBLIC WITH_OPENCL)
     target_include_directories(mandel SYSTEM PUBLIC ${OpenCL_INCLUDE_DIRS})
     target_include_directories(mandel SYSTEM PUBLIC "include_cl")
     link_directories(${OpenCL_LIBRARY})
     target_link_libraries(mandel PUBLIC OpenCL::OpenCL)
-else(OPENCL_FOUND)
-endif(OPENCL_FOUND)
+else()
+endif()
 
 if (APPLE AND OpenCL_FOUND)
     SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -framework OpenCL")

+ 3 - 0
libmandel/src/IterationCompiler.cpp

@@ -816,6 +816,8 @@ namespace mnd
         printf("ir: %s\n", irf.toString().c_str()); fflush(stdout);
         irf.optimize();
         printf("ir: %s\n", irf.toString().c_str()); fflush(stdout);
+
+#ifdef WITH_OPENCL
         auto fl = compileCl(irf, dev);
         vec.push_back(std::move(fl));
         if (dev.supportsDouble()) {
@@ -823,6 +825,7 @@ namespace mnd
             auto fld = compileClDouble(irf, dev);
             vec.push_back(std::move(fld));
         }
+#endif // WITH_OPENCL
 
         return vec;// { { mnd::GeneratorType::FLOAT, std::move(fl) } };
     }

+ 2 - 0
libmandel/src/Mandel.cpp

@@ -29,9 +29,11 @@ MandelDevice::MandelDevice(mnd::ClDeviceWrapper device, const std::string& platf
     clDevice{ std::make_unique<ClDeviceWrapper>(std::move(device)) },
     platformName{ platformName }
 {
+#ifdef WITH_OPENCL
     extensions = clDevice->device.getInfo<CL_DEVICE_EXTENSIONS>();
     name = clDevice->device.getInfo<CL_DEVICE_NAME>();
     vendor = clDevice->device.getInfo<CL_DEVICE_VENDOR>();
+#endif // WITH_OPENCL
 }