Skip to content

Commit

Permalink
WIP Migrate C2H library to top-level.
Browse files Browse the repository at this point in the history
[skip-docs][skip-vdc][skip-rapids]
  • Loading branch information
alliepiper committed Oct 28, 2024
1 parent ca5dbf9 commit 0b4db50
Show file tree
Hide file tree
Showing 124 changed files with 1,412 additions and 1,377 deletions.
39 changes: 39 additions & 0 deletions c2h/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.21)

project(C2H LANGUAGES CXX CUDA)

cccl_get_catch2()

find_package(CCCL CONFIG REQUIRED
NO_DEFAULT_PATH # Only check the explicit HINTS below:
HINTS "${CCCL_SOURCE_DIR}/lib/cmake/cccl/"
)

find_package(CUDAToolkit)

set(curand_default OFF)
if (CUDA_curand_LIBRARY)
set(curand_default ON)
endif()

option(C2H_ENABLE_CURAND "Use CUDA CURAND library in c2h." ${curand_default})

add_library(cccl.c2h STATIC generators.cu)
target_include_directories(cccl.c2h PUBLIC "${C2H_SOURCE_DIR}/include")
target_link_libraries(cccl.c2h PUBLIC
CCCL::CCCL
Catch2::Catch2
)

if (C2H_ENABLE_CURAND)
target_link_libraries(cccl.c2h PRIVATE CUDA::curand)
target_compile_definitions(cccl.c2h PRIVATE C2H_HAS_CURAND=1)
else()
target_compile_definitions(cccl.c2h PRIVATE C2H_HAS_CURAND=0)
endif()

add_library(cccl.c2h.main OBJECT
catch2_runner.cpp
catch2_runner_helper.cu
)
target_link_libraries(cccl.c2h.main PUBLIC cccl.c2h)
2 changes: 1 addition & 1 deletion cub/test/catch2_runner.cpp → c2h/catch2_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@

#define CUB_CONFIG_MAIN
#define CUB_EXCLUDE_CATCH2_HELPER_IMPL
#include "catch2_main.cuh"
#include <c2h/catch2_main.cuh>
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cub/test/c2h/generators.cu → c2h/generators.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
#include <c2h/custom_type.cuh>
#include <c2h/device_policy.cuh>
#include <c2h/extended_types.cuh>
#include <c2h/fill_striped.cuh>
#include <c2h/generators.cuh>
#include <c2h/vector.cuh>
#include <fill_striped.cuh>

#if C2H_HAS_CURAND
# include <curand.h>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <catch2/catch.hpp>

#if defined(CUB_CONFIG_MAIN)
# include "catch2_runner_helper.h"
# include <c2h/catch2_runner_helper.cuh>

# if !defined(CUB_EXCLUDE_CATCH2_HELPER_IMPL)
# include "catch2_runner_helper.inl"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@

#include <cub/util_compiler.cuh>

#include <cuda/std/__cccl/diagnostic.h>

#include <cstdint>
#include <cstdlib>
#include <tuple>
#include <type_traits>

#include "cuda/std/__cccl/diagnostic.h"
#include "test_util_vec.h"

#if __CUDACC_VER_MAJOR__ == 11
_CCCL_NV_DIAG_SUPPRESS(177) // catch2 may contain unused variableds
#endif // nvcc-11
Expand All @@ -46,9 +45,9 @@ _CCCL_NV_DIAG_SUPPRESS(177) // catch2 may contain unused variableds
#include <cuda/std/type_traits>
#include <cuda/std/utility>

#include "catch2_main.cuh"
#include "test_warning_suppression.cuh"
#include <c2h/catch2_main.cuh>
#include <c2h/device_policy.cuh>
#include <c2h/test_util_vec.cuh>
#include <c2h/utility.cuh>
#include <c2h/vector.cuh>

Expand Down Expand Up @@ -234,26 +233,26 @@ struct Catch::StringMaker<cudaError>
#include <c2h/custom_type.cuh>
#include <c2h/generators.cuh>

#define CUB_TEST_NAME_IMPL(NAME, PARAM) CUB_TEST_STR(NAME) "(" CUB_TEST_STR(PARAM) ")"
#define C2H_TEST_NAME_IMPL(NAME, PARAM) C2H_TEST_STR(NAME) "(" C2H_TEST_STR(PARAM) ")"

#define CUB_TEST_NAME(NAME) CUB_TEST_NAME_IMPL(NAME, VAR_IDX)
#define C2H_TEST_NAME(NAME) C2H_TEST_NAME_IMPL(NAME, VAR_IDX)

#define CUB_TEST_CONCAT(A, B) CUB_TEST_CONCAT_INNER(A, B)
#define CUB_TEST_CONCAT_INNER(A, B) A##B
#define C2H_TEST_CONCAT(A, B) C2H_TEST_CONCAT_INNER(A, B)
#define C2H_TEST_CONCAT_INNER(A, B) A##B

#define CUB_TEST_IMPL(ID, NAME, TAG, ...) \
using CUB_TEST_CONCAT(types_, ID) = c2h::cartesian_product<__VA_ARGS__>; \
TEMPLATE_LIST_TEST_CASE(CUB_TEST_NAME(NAME), TAG, CUB_TEST_CONCAT(types_, ID))
#define C2H_TEST_IMPL(ID, NAME, TAG, ...) \
using C2H_TEST_CONCAT(types_, ID) = c2h::cartesian_product<__VA_ARGS__>; \
TEMPLATE_LIST_TEST_CASE(C2H_TEST_NAME(NAME), TAG, C2H_TEST_CONCAT(types_, ID))

#define CUB_TEST(NAME, TAG, ...) CUB_TEST_IMPL(__LINE__, NAME, TAG, __VA_ARGS__)
#define C2H_TEST(NAME, TAG, ...) C2H_TEST_IMPL(__LINE__, NAME, TAG, __VA_ARGS__)

#define CUB_TEST_LIST_IMPL(ID, NAME, TAG, ...) \
using CUB_TEST_CONCAT(types_, ID) = c2h::type_list<__VA_ARGS__>; \
TEMPLATE_LIST_TEST_CASE(CUB_TEST_NAME(NAME), TAG, CUB_TEST_CONCAT(types_, ID))
#define C2H_TEST_LIST_IMPL(ID, NAME, TAG, ...) \
using C2H_TEST_CONCAT(types_, ID) = c2h::type_list<__VA_ARGS__>; \
TEMPLATE_LIST_TEST_CASE(C2H_TEST_NAME(NAME), TAG, C2H_TEST_CONCAT(types_, ID))

#define CUB_TEST_LIST(NAME, TAG, ...) CUB_TEST_LIST_IMPL(__LINE__, NAME, TAG, __VA_ARGS__)
#define C2H_TEST_LIST(NAME, TAG, ...) C2H_TEST_LIST_IMPL(__LINE__, NAME, TAG, __VA_ARGS__)

#define CUB_TEST_STR(a) #a
#define C2H_TEST_STR(a) #a

namespace detail
{
Expand All @@ -267,7 +266,7 @@ inline std::size_t adjust_seed_count(std::size_t requested)
}
} // namespace detail

#define CUB_SEED(N) \
#define C2H_SEED(N) \
c2h::seed_t \
{ \
GENERATE_COPY(take( \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
#ifdef TEST_HALF_T
# include <cuda_fp16.h>

# include "../half.h"
# include <c2h/half.cuh>
#endif

#ifdef TEST_BF_T
# include <cuda_bf16.h>

# include "../bfloat16.h"
# include <c2h/bfloat16.cuh>
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0b4db50

Please sign in to comment.