Compare commits
No commits in common. "4b474e21edde39ece5c605c517ee8bf320437611" and "9f1e9881d6837ccaf2e077821e9e28a1163c1dfa" have entirely different histories.
4b474e21ed
...
9f1e9881d6
8 changed files with 0 additions and 115 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +0,0 @@
|
||||||
.idea/*
|
|
||||||
cmake-*
|
|
||||||
build/
|
|
|
@ -1,29 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
|
||||||
project(raiiSafeCuda CXX)
|
|
||||||
|
|
||||||
option(ENABLE_TESTS "Enable tests' cmake target." ON)
|
|
||||||
|
|
||||||
find_package(CUDAToolkit REQUIRED)
|
|
||||||
|
|
||||||
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 $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
|
|
||||||
target_compile_options(raiiSafeCuda PRIVATE -pipe -Wall -Wextra -pedantic)
|
|
||||||
target_link_libraries(raiiSafeCuda CUDA::cudart)
|
|
||||||
|
|
||||||
set_target_properties(raiiSafeCuda PROPERTIES
|
|
||||||
CXX_STANDARD 20
|
|
||||||
CXX_EXTENSIONS OFF
|
|
||||||
INTERPROCEDURAL_OPTIMIZATION ON
|
|
||||||
)
|
|
||||||
|
|
||||||
if (ENABLE_TESTS)
|
|
||||||
add_subdirectory(tests)
|
|
||||||
endif ()
|
|
|
@ -1,12 +0,0 @@
|
||||||
//
|
|
||||||
// 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
|
|
|
@ -1,18 +0,0 @@
|
||||||
#ifndef RAIISAFECUDA_STREAM_RELATED_HPP
|
|
||||||
#define RAIISAFECUDA_STREAM_RELATED_HPP
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <cuda_runtime_api.h>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
namespace safe_cuda {
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
std::variant<std::unique_ptr<CUstream_st, streamDestroyType>, cudaError_t> create_stream() noexcept;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //RAIISAFECUDA_STREAM_RELATED_HPP
|
|
|
@ -1,5 +0,0 @@
|
||||||
//
|
|
||||||
// Created by postaron on 25/03/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "malloc_unmanagef.hpp"
|
|
|
@ -1,13 +0,0 @@
|
||||||
#include "stream_related.hpp"
|
|
||||||
|
|
||||||
namespace safe_cuda {
|
|
||||||
std::variant<std::unique_ptr<CUstream_st, streamDestroyType>, cudaError_t> create_stream() noexcept {
|
|
||||||
cudaStream_t stream = nullptr;
|
|
||||||
const cudaError_t error = cudaStreamCreate(&stream);
|
|
||||||
if (error != cudaSuccess) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
return std::unique_ptr<CUstream_st, streamDestroyType>{ stream, cudaStreamDestroy };
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
project(testsRaiiSafeCuda CXX)
|
|
||||||
|
|
||||||
find_package(Catch2 3)
|
|
||||||
if (NOT Catch2_FOUND)
|
|
||||||
message(STATUS "Using FetchContent to download and use Catch2")
|
|
||||||
include(FetchContent)
|
|
||||||
fetchcontent_declare(
|
|
||||||
Catch2
|
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2
|
|
||||||
GIT_TAG v3.5.3
|
|
||||||
EXCLUDE_FROM_ALL
|
|
||||||
OVERRIDE_FIND_PACKAGE
|
|
||||||
)
|
|
||||||
fetchcontent_makeavailable(Catch2)
|
|
||||||
find_package(Catch2 3 REQUIRED)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include(CTest)
|
|
||||||
enable_testing()
|
|
||||||
include(Catch)
|
|
||||||
include(CatchAddTests)
|
|
||||||
|
|
||||||
add_executable(tests tests_stream.cpp)
|
|
||||||
target_link_libraries(tests Catch2::Catch2WithMain)
|
|
||||||
|
|
||||||
catch_discover_tests(tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
@ -1,9 +0,0 @@
|
||||||
//
|
|
||||||
// Created by postaron on 21/03/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <catch2/catch_all.hpp>
|
|
||||||
|
|
||||||
TEST_CASE("hello", "world") {
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue