Skip to content

Commit

Permalink
Fix no-cuda build (#484)
Browse files Browse the repository at this point in the history
Closes #482

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)
  - Bradley Dice (https://github.com/bdice)

URL: #484
  • Loading branch information
madsbk authored Oct 3, 2024
1 parent e66b83b commit 5a733bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ if(KvikIO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(KvikIO_BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
if(CUDAToolkit_FOUND
AND KvikIO_BUILD_TESTS
AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME
)
include(cmake/thirdparty/get_gtest.cmake)

# include CTest module -- automatically calls enable_testing()
Expand Down
10 changes: 10 additions & 0 deletions cpp/include/kvikio/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <tuple>
#include <type_traits>

#ifdef KVIKIO_CUDA_FOUND
#include <nvtx3/nvtx3.hpp>
#endif

#include <kvikio/error.hpp>
#include <kvikio/shim/cuda.hpp>
Expand Down Expand Up @@ -291,6 +293,7 @@ inline bool is_future_done(const T& future)
return future.wait_for(std::chrono::seconds(0)) != std::future_status::timeout;
}

#ifdef KVIKIO_CUDA_FOUND
/**
* @brief Tag type for libkvikio's NVTX domain.
*/
Expand All @@ -309,6 +312,7 @@ struct libkvikio_domain {
} \
}
#define GET_KVIKIO_NVTX_FUNC_RANGE_MACRO(_1, _2, NAME, ...) NAME
#endif

/**
* @brief Convenience macro for generating an NVTX range in the `libkvikio` domain
Expand All @@ -329,9 +333,15 @@ struct libkvikio_domain {
* }
* ```
*/
#ifdef KVIKIO_CUDA_FOUND
#define KVIKIO_NVTX_FUNC_RANGE(...) \
GET_KVIKIO_NVTX_FUNC_RANGE_MACRO( \
__VA_ARGS__, KVIKIO_NVTX_FUNC_RANGE_2, KVIKIO_NVTX_FUNC_RANGE_1) \
(__VA_ARGS__)
#else
#define KVIKIO_NVTX_FUNC_RANGE(...) \
do { \
} while (0)
#endif

} // namespace kvikio

0 comments on commit 5a733bd

Please sign in to comment.