diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt --- a/openmp/libomptarget/CMakeLists.txt +++ b/openmp/libomptarget/CMakeLists.txt @@ -37,6 +37,9 @@ include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS}) +# Build the device RTL before we set the libomptarget include directories. +add_subdirectory(DeviceRTL) + # This is a list of all the targets that are supported/tested right now. set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu") set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu-oldDriver") @@ -85,7 +88,6 @@ # Build offloading plugins and device RTLs if they are available. add_subdirectory(plugins) -add_subdirectory(DeviceRTL) add_subdirectory(tools) # Add tests. diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt --- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt +++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt @@ -241,3 +241,22 @@ foreach(mcpu ${amdgpu_mcpus}) compileDeviceRTLLibrary(${mcpu} amdgpu -target amdgcn-amd-amdhsa -D__AMDGCN__ -nogpulib) endforeach() + +# Set the flags to build the device runtime from clang. +set(clang_lib_flags -fopenmp -fopenmp-cuda-mode -foffload-lto -fvisibility=hidden -mllvm -openmp-opt-disable -nogpulib -nostdinc -DSHARED_SCRATCHPAD_SIZE=512) +foreach(arch ${nvptx_sm_list}) + set(clang_lib_flags ${clang_lib_flags} --offload-arch=sm_${arch}) +endforeach() +foreach(arch ${amdgpu_mcpus}) + set(clang_lib_flags ${clang_lib_flags} --offload-arch=${arch}) +endforeach() + +# Build the static library version of the device runtime. +add_library(omptarget.devicertl STATIC) +target_compile_features(omptarget.devicertl PRIVATE cxx_std_17) +target_include_directories(omptarget.devicertl PRIVATE ${include_directory} ${devicertl_base_directory}/../include) +target_compile_options(omptarget.devicertl PRIVATE ${clang_lib_flags}) + +install(TARGETS omptarget.devicertl ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR}) + +add_subdirectory(src) diff --git a/openmp/libomptarget/DeviceRTL/src/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/src/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/openmp/libomptarget/DeviceRTL/src/CMakeLists.txt @@ -0,0 +1,13 @@ +target_sources(omptarget.devicertl PRIVATE + Configuration.cpp + Debug.cpp + Kernel.cpp + Mapping.cpp + Misc.cpp + Parallelism.cpp + Reduction.cpp + State.cpp + Synchronization.cpp + Tasking.cpp + Utils.cpp + Workshare.cpp)