diff --git a/CMakeLists.txt b/CMakeLists.txt index c25b0a1..a83ad04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,15 @@ option(ENABLE_TESTS "Enable tests' cmake target." ON) find_package(CUDAToolkit REQUIRED) -add_library(raiiSafeCuda SHARED safe_cuda/stream_related.cpp) +file(GLOB_RECURSE SAFE_CUDA_HEADERS include/*.hpp) +file(GLOB_RECURSE SAFE_CUDA_SOURCES src/*.cpp) + + +add_library(raiiSafeCuda SHARED + ${SAFE_CUDA_HEADERS} + ${SAFE_CUDA_SOURCES} +) +target_precompile_headers(raiiSafeCuda PRIVATE ${SAFE_CUDA_HEADERS}) target_compile_definitions(raiiSafeCuda PRIVATE $<$:_GLIBCXX_DEBUG>) target_compile_options(raiiSafeCuda PRIVATE -pipe -Wall -Wextra -pedantic) target_link_libraries(raiiSafeCuda CUDA::cudart) diff --git a/include/malloc_unmanagef.hpp b/include/malloc_unmanagef.hpp new file mode 100644 index 0000000..3a8f745 --- /dev/null +++ b/include/malloc_unmanagef.hpp @@ -0,0 +1,12 @@ +// +// Created by postaron on 25/03/24. +// + +#ifndef RAIISAFECUDA_MALLOC_UNMANAGEF_HPP +#define RAIISAFECUDA_MALLOC_UNMANAGEF_HPP + +namespace safe_cuda { + +} + +#endif //RAIISAFECUDA_MALLOC_UNMANAGEF_HPP diff --git a/safe_cuda/stream_related.h b/include/stream_related.hpp similarity index 54% rename from safe_cuda/stream_related.h rename to include/stream_related.hpp index 64cb03c..17594b4 100644 --- a/safe_cuda/stream_related.h +++ b/include/stream_related.hpp @@ -1,21 +1,18 @@ -#ifndef RAIISAFECUDA_STREAM_RELATED_H -#define RAIISAFECUDA_STREAM_RELATED_H +#ifndef RAIISAFECUDA_STREAM_RELATED_HPP +#define RAIISAFECUDA_STREAM_RELATED_HPP #include #include #include namespace safe_cuda { - template - using returnType = std::variant; - using streamDestroyType = decltype(&cudaStreamDestroy); /** * \brief It tries to create a stream, putting it in a smart pointer with its correct destructor. * \return smart pointer if creation is OK, else the CUDA error */ - returnType> create_stream() noexcept; + std::variant, cudaError_t> create_stream() noexcept; } -#endif //RAIISAFECUDA_STREAM_RELATED_H +#endif //RAIISAFECUDA_STREAM_RELATED_HPP diff --git a/src/malloc_unmanagef.cpp b/src/malloc_unmanagef.cpp new file mode 100644 index 0000000..bd282b5 --- /dev/null +++ b/src/malloc_unmanagef.cpp @@ -0,0 +1,5 @@ +// +// Created by postaron on 25/03/24. +// + +#include "malloc_unmanagef.hpp" diff --git a/safe_cuda/stream_related.cpp b/src/stream_related.cpp similarity index 68% rename from safe_cuda/stream_related.cpp rename to src/stream_related.cpp index 666a41d..a863685 100644 --- a/safe_cuda/stream_related.cpp +++ b/src/stream_related.cpp @@ -1,7 +1,7 @@ -#include "stream_related.h" +#include "stream_related.hpp" namespace safe_cuda { - returnType> create_stream() noexcept { + std::variant, cudaError_t> create_stream() noexcept { cudaStream_t stream = nullptr; const cudaError_t error = cudaStreamCreate(&stream); if (error != cudaSuccess) {