diff --git a/fpga/.gitmodules b/fpga/.gitmodules index e84b2462c..0e6e035f1 100644 --- a/fpga/.gitmodules +++ b/fpga/.gitmodules @@ -5,7 +5,7 @@ path = thirdparty/libxil url = https://git.rwth-aachen.de/acs/public/villas/libxil.git [submodule "lib/gpu/gdrcopy"] - path = lib/gpu/gdrcopy + path = gpu/thirdparty/gdrcopy url = https://github.com/daniel-k/gdrcopy.git [submodule "thirdparty/udmabuf"] path = thirdparty/udmabuf diff --git a/fpga/CMakeLists.txt b/fpga/CMakeLists.txt index 3d506afea..51314b898 100644 --- a/fpga/CMakeLists.txt +++ b/fpga/CMakeLists.txt @@ -33,6 +33,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") include(CheckLanguage) check_language(CUDA) +if(CMAKE_CUDA_COMPILER) + add_subdirectory(gpu) +else() + message("No CUDA support, not building GPU library") +endif() + include_directories(thirdparty/CLI11) include_directories(thirdparty/rang) diff --git a/fpga/lib/gpu/CMakeLists.txt b/fpga/gpu/CMakeLists.txt similarity index 77% rename from fpga/lib/gpu/CMakeLists.txt rename to fpga/gpu/CMakeLists.txt index 1c17ad0a2..67ea86dec 100644 --- a/fpga/lib/gpu/CMakeLists.txt +++ b/fpga/gpu/CMakeLists.txt @@ -27,22 +27,35 @@ project(villas-gpu DESCRIPTION "VILLASgpu" LANGUAGES C CXX CUDA) -add_subdirectory(gdrcopy) +add_subdirectory(thirdparty/gdrcopy) -add_library(villas-gpu SHARED gpu.cpp kernels.cu) +add_library(villas-gpu + SHARED + src/gpu.cpp + src/kernels.cu +) target_compile_options(villas-gpu PRIVATE -g) -set_source_files_properties(gpu.cpp PROPERTIES - LANGUAGE CUDA) +set_source_files_properties(src/gpu.cpp PROPERTIES + LANGUAGE CUDA +) -target_include_directories(villas-gpu PRIVATE /opt/cuda/include) +target_include_directories(villas-gpu + PRIVATE + /opt/cuda/include +) target_link_libraries(villas-gpu - PUBLIC villas-common gdrapi cuda) + PUBLIC + villas-common + gdrapi + cuda +) target_include_directories(villas-gpu PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/include + ${CMAKE_CURRENT_LIST_DIR}/include PRIVATE - ${CMAKE_CURRENT_LIST_DIR}) + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/fpga/lib/gpu/include/villas/gpu.hpp b/fpga/gpu/include/villas/gpu.hpp similarity index 100% rename from fpga/lib/gpu/include/villas/gpu.hpp rename to fpga/gpu/include/villas/gpu.hpp diff --git a/fpga/lib/gpu/kernels.hpp b/fpga/gpu/kernels.hpp similarity index 100% rename from fpga/lib/gpu/kernels.hpp rename to fpga/gpu/kernels.hpp diff --git a/fpga/lib/gpu/gpu.cpp b/fpga/gpu/src/gpu.cpp similarity index 100% rename from fpga/lib/gpu/gpu.cpp rename to fpga/gpu/src/gpu.cpp diff --git a/fpga/lib/gpu/kernels.cu b/fpga/gpu/src/kernels.cu similarity index 98% rename from fpga/lib/gpu/kernels.cu rename to fpga/gpu/src/kernels.cu index 14a0d47b7..1bc759d07 100644 --- a/fpga/lib/gpu/kernels.cu +++ b/fpga/gpu/src/kernels.cu @@ -24,11 +24,12 @@ #include #include -#include "kernels.hpp" -#include "cuda_runtime.h" +#include #include +#include "kernels.hpp" + namespace villas { namespace gpu { diff --git a/fpga/lib/gpu/gdrcopy b/fpga/gpu/thirdparty/gdrcopy similarity index 100% rename from fpga/lib/gpu/gdrcopy rename to fpga/gpu/thirdparty/gdrcopy diff --git a/fpga/lib/CMakeLists.txt b/fpga/lib/CMakeLists.txt index f3fe630f8..307b6f98c 100644 --- a/fpga/lib/CMakeLists.txt +++ b/fpga/lib/CMakeLists.txt @@ -55,13 +55,6 @@ add_library(villas-fpga SHARED ${SOURCES}) target_link_libraries(villas-fpga PUBLIC villas-common) -if(CMAKE_CUDA_COMPILER) - add_subdirectory(gpu) - target_link_libraries(villas-fpga PUBLIC villas-gpu) -else() - message("No CUDA support, not building GPU library") -endif() - target_compile_definitions(villas-fpga PRIVATE BUILDID=\"abc\" _GNU_SOURCE @@ -83,6 +76,10 @@ target_link_libraries(villas-fpga PUBLIC villas-common ) +if(CMAKE_CUDA_COMPILER) + target_link_libraries(villas-fpga PUBLIC villas-gpu) +endif() + include(GNUInstallDirs) install(TARGETS villas-fpga