From 1e6a34f8f9ad24248e313ab77f66cd1227d18d86 Mon Sep 17 00:00:00 2001 From: "LEGOLAS\\lenz" <lenz@irmb.tu-bs.de> Date: Wed, 16 Oct 2019 14:03:33 +0200 Subject: [PATCH] enables OpenMP for GKS computations on CPU --- CMakeMacros/OpenMP/Link.cmake | 1 + src/GksGpu/CudaUtility/CudaRunKernel.hpp | 4 +++- targets/libs/GksGpu/3rdPartyLinking.cmake | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeMacros/OpenMP/Link.cmake b/CMakeMacros/OpenMP/Link.cmake index f74f01f72..2a5ae6710 100644 --- a/CMakeMacros/OpenMP/Link.cmake +++ b/CMakeMacros/OpenMP/Link.cmake @@ -4,6 +4,7 @@ find_package(OpenMP) if (OPENMP_FOUND) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler ${OpenMP_CXX_FLAGS}") endif() endmacro(linkOpenMP) diff --git a/src/GksGpu/CudaUtility/CudaRunKernel.hpp b/src/GksGpu/CudaUtility/CudaRunKernel.hpp index 4945cca05..545cd4114 100644 --- a/src/GksGpu/CudaUtility/CudaRunKernel.hpp +++ b/src/GksGpu/CudaUtility/CudaRunKernel.hpp @@ -35,6 +35,7 @@ #include <string> #include <device_launch_parameters.h> +#include <omp.h> #include "CudaUtility/CudaUtility.h" @@ -49,7 +50,8 @@ void runKernel(KernelFunctor kernel, FunctionFunctor function, std::string devic } else { - for( uint index = 0; index < grid.numberOfEntities; index++ ) +#pragma omp parallel for + for( int index = 0; index < grid.numberOfEntities; index++ ) { function( args..., index ); } diff --git a/targets/libs/GksGpu/3rdPartyLinking.cmake b/targets/libs/GksGpu/3rdPartyLinking.cmake index 7898b5083..efc76a96b 100644 --- a/targets/libs/GksGpu/3rdPartyLinking.cmake +++ b/targets/libs/GksGpu/3rdPartyLinking.cmake @@ -1,2 +1,4 @@ include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) linkCuda(${targetName}) +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/OpenMP/Link.cmake) +linkOpenMP(${targetName}) -- GitLab