Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions libcudacxx/cmake/LibcudacxxPublicHeaderTestingHost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@

# Meta target for all configs' header builds:
add_custom_target(libcudacxx.test.public_headers_host_only)
add_custom_target(libcudacxx.test.public_headers_host_only_with_ctk)

# Grep all public headers
file(
GLOB public_headers_host_only
LIST_DIRECTORIES false
RELATIVE "${libcudacxx_SOURCE_DIR}/include"
CONFIGURE_DEPENDS
"${libcudacxx_SOURCE_DIR}/include/cuda/*"
"${libcudacxx_SOURCE_DIR}/include/cuda/std/*"
# Add some files we expect to work in host only compilation
"${libcudacxx_SOURCE_DIR}/include/cuda/bit"
"${libcudacxx_SOURCE_DIR}/include/cuda/cmath"
"${libcudacxx_SOURCE_DIR}/include/cuda/functional"
"${libcudacxx_SOURCE_DIR}/include/cuda/iterator"
"${libcudacxx_SOURCE_DIR}/include/cuda/mdspan"
"${libcudacxx_SOURCE_DIR}/include/cuda/memory"
"${libcudacxx_SOURCE_DIR}/include/cuda/numeric"
"${libcudacxx_SOURCE_DIR}/include/cuda/type_traits"
"${libcudacxx_SOURCE_DIR}/include/cuda/utility"
"${libcudacxx_SOURCE_DIR}/include/cuda/version"
)

set(public_host_header_cxx_compile_options)
Expand Down Expand Up @@ -63,6 +54,38 @@ function(libcudacxx_create_public_header_test_host header_name headertest_src)
)
endfunction()

function(
libcudacxx_create_public_header_test_host_with_ctk
header_name
headertest_src
)
# Create the default target for that file
add_library(
public_headers_host_only_with_ctk_${header_name}
SHARED
"${headertest_src}.cpp"
)
cccl_configure_target(public_headers_host_only_with_ctk_${header_name})
target_compile_definitions(
public_headers_host_only_with_ctk_${header_name}
PRIVATE #
${public_host_header_cxx_compile_definitions}
_CCCL_HEADER_TEST
)
target_compile_options(
public_headers_host_only_with_ctk_${header_name}
PRIVATE ${public_host_header_cxx_compile_options}
)
target_link_libraries(
public_headers_host_only_with_ctk_${header_name}
PUBLIC libcudacxx.compiler_interface CUDA::cudart
)
add_dependencies(
libcudacxx.test.public_headers_host_only_with_ctk
public_headers_host_only_with_ctk_${header_name}
)
endfunction()

function(libcudacxx_add_public_headers_host_only header)
# ${header} contains the "/" from the subfolder, replace by "_" for actual names
string(REPLACE "/" "_" header_name "${header}")
Expand All @@ -76,6 +99,7 @@ function(libcudacxx_add_public_headers_host_only header)

# Create the default target for that file
libcudacxx_create_public_header_test_host(${header_name} ${headertest_src})
libcudacxx_create_public_header_test_host_with_ctk(${header_name} ${headertest_src})
endfunction()

foreach (header IN LISTS public_headers_host_only)
Expand Down
78 changes: 41 additions & 37 deletions libcudacxx/include/cuda/__container/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,37 @@
# pragma system_header
#endif // no system header

#if _CCCL_CUDA_COMPILATION()
# include <cub/device/device_transform.cuh>
#endif // _CCCL_CUDA_COMPILATION()

#include <cuda/__container/heterogeneous_iterator.h>
#include <cuda/__container/uninitialized_async_buffer.h>
#include <cuda/__launch/host_launch.h>
#include <cuda/__memory_resource/any_resource.h>
#include <cuda/__memory_resource/get_memory_resource.h>
#include <cuda/__memory_resource/properties.h>
#include <cuda/__memory_resource/synchronous_resource_adapter.h>
#include <cuda/__runtime/ensure_current_context.h>
#include <cuda/__stream/get_stream.h>
#include <cuda/std/__execution/env.h>
#include <cuda/std/__iterator/concepts.h>
#include <cuda/std/__iterator/distance.h>
#include <cuda/std/__iterator/reverse_iterator.h>
#include <cuda/std/__memory/uninitialized_algorithms.h>
#include <cuda/std/__ranges/access.h>
#include <cuda/std/__ranges/concepts.h>
#include <cuda/std/__ranges/size.h>
#include <cuda/std/__ranges/unwrap_end.h>
#include <cuda/std/__type_traits/is_trivially_copyable.h>
#include <cuda/std/__utility/forward.h>
#include <cuda/std/__utility/move.h>
#include <cuda/std/cstdint>
#include <cuda/std/initializer_list>

#include <cuda/std/__cccl/prologue.h>
#if _CCCL_HAS_CTK()

# if _CCCL_CUDA_COMPILATION()
# include <cub/device/device_transform.cuh>
# endif // _CCCL_CUDA_COMPILATION()

# include <cuda/__container/heterogeneous_iterator.h>
# include <cuda/__container/uninitialized_async_buffer.h>
# include <cuda/__launch/host_launch.h>
# include <cuda/__memory_resource/any_resource.h>
# include <cuda/__memory_resource/get_memory_resource.h>
# include <cuda/__memory_resource/properties.h>
# include <cuda/__memory_resource/synchronous_resource_adapter.h>
# include <cuda/__runtime/ensure_current_context.h>
# include <cuda/__stream/get_stream.h>
# include <cuda/std/__execution/env.h>
# include <cuda/std/__iterator/concepts.h>
# include <cuda/std/__iterator/distance.h>
# include <cuda/std/__iterator/reverse_iterator.h>
# include <cuda/std/__memory/uninitialized_algorithms.h>
# include <cuda/std/__ranges/access.h>
# include <cuda/std/__ranges/concepts.h>
# include <cuda/std/__ranges/size.h>
# include <cuda/std/__ranges/unwrap_end.h>
# include <cuda/std/__type_traits/is_trivially_copyable.h>
# include <cuda/std/__utility/forward.h>
# include <cuda/std/__utility/move.h>
# include <cuda/std/cstdint>
# include <cuda/std/initializer_list>

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

//! @file The \c buffer class provides a container of contiguous memory
_CCCL_BEGIN_NAMESPACE_CUDA
Expand Down Expand Up @@ -309,7 +311,7 @@ class buffer
__buf_.size());
}

#ifndef _CCCL_DOXYGEN_INVOKED // doxygen conflates the overloads
# ifndef _CCCL_DOXYGEN_INVOKED // doxygen conflates the overloads
_CCCL_TEMPLATE(class _Range, class _Resource, class _Env = ::cuda::std::execution::env<>)
_CCCL_REQUIRES(
::cuda::mr::synchronous_resource<::cuda::std::decay_t<_Resource>> _CCCL_AND __compatible_range<_Range>
Expand All @@ -332,7 +334,7 @@ class buffer
__unwrapped_begin(),
__buf_.size());
}
#endif // _CCCL_DOXYGEN_INVOKED
# endif // _CCCL_DOXYGEN_INVOKED
//! @}

//! @addtogroup iterators
Expand Down Expand Up @@ -447,7 +449,7 @@ class buffer
return __buf_.data();
}

#ifndef _CCCL_DOXYGEN_INVOKED
# ifndef _CCCL_DOXYGEN_INVOKED
//! @brief Returns a pointer to the first element of the buffer. If the buffer
//! is empty, the returned pointer will be null.
[[nodiscard]] _CCCL_HIDE_FROM_ABI pointer __unwrapped_begin() noexcept
Expand Down Expand Up @@ -477,7 +479,7 @@ class buffer
{
return __buf_.data() + __buf_.size();
}
#endif // _CCCL_DOXYGEN_INVOKED
# endif // _CCCL_DOXYGEN_INVOKED

//! @}

Expand Down Expand Up @@ -683,13 +685,13 @@ __fill_n(cuda::stream_ref __stream, _Tp* __first, ::cuda::std::size_t __count, c
}
else
{
#if _CCCL_CUDA_COMPILATION()
# if _CCCL_CUDA_COMPILATION()
::cuda::__ensure_current_context __guard(__stream);
::cub::DeviceTransform::Fill(__first, __count, __value, __stream.get());
#else // ^^^ _CCCL_CUDA_COMPILATION() ^^^ / vvv !_CCCL_CUDA_COMPILATION() vvv
# else // ^^^ _CCCL_CUDA_COMPILATION() ^^^ / vvv !_CCCL_CUDA_COMPILATION() vvv
static_assert(sizeof(_Tp) <= 4,
"CUDA compiler is required to initialize an async_buffer with elements larger than 4 bytes");
#endif // ^^^ !_CCCL_CUDA_COMPILATION() ^^^
# endif // ^^^ !_CCCL_CUDA_COMPILATION() ^^^
}
}
}
Expand Down Expand Up @@ -886,6 +888,8 @@ auto make_buffer(stream_ref __stream, _Resource&& __mr, _Range&& __range, const
}
_CCCL_END_NAMESPACE_CUDA

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

#endif // _CCCL_HAS_CTK()

#endif //_CUDA___CONTAINER_BUFFER_H
46 changes: 25 additions & 21 deletions libcudacxx/include/cuda/__container/heterogeneous_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@
# pragma system_header
#endif // no system header

#include <cuda/__memory_resource/properties.h>
#include <cuda/std/__iterator/iterator_traits.h>
#include <cuda/std/__memory/addressof.h>
#include <cuda/std/__memory/pointer_traits.h>
#include <cuda/std/__type_traits/is_const.h>
#include <cuda/std/__type_traits/is_same.h>
#include <cuda/std/__type_traits/maybe_const.h>
#include <cuda/std/__type_traits/remove_const.h>
#include <cuda/std/cstdint>

#include <cuda/std/__cccl/prologue.h>
#if _CCCL_HAS_CTK()

# include <cuda/__memory_resource/properties.h>
# include <cuda/std/__iterator/iterator_traits.h>
# include <cuda/std/__memory/addressof.h>
# include <cuda/std/__memory/pointer_traits.h>
# include <cuda/std/__type_traits/is_const.h>
# include <cuda/std/__type_traits/is_same.h>
# include <cuda/std/__type_traits/maybe_const.h>
# include <cuda/std/__type_traits/remove_const.h>
# include <cuda/std/cstdint>

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

//! @file The \c heterogeneous_iterator class is an iterator that provides typed execution space safety.
_CCCL_BEGIN_NAMESPACE_CUDA
Expand Down Expand Up @@ -290,7 +292,7 @@ class heterogeneous_iterator
return __temp;
}

#ifndef _CCCL_DOXYGEN_INVOKED // Do not document
# ifndef _CCCL_DOXYGEN_INVOKED // Do not document
//! @brief Advance a \c heterogeneous_iterator
//! @param __count The number of elements to advance.
//! @param __other A heterogeneous_iterator.
Expand All @@ -301,7 +303,7 @@ class heterogeneous_iterator
__other += __count;
return __other;
}
#endif // _CCCL_DOXYGEN_INVOKED
# endif // _CCCL_DOXYGEN_INVOKED

//! @brief Advance a \c heterogeneous_iterator by the negative value of \p __count
//! @param __count The number of elements to advance.
Expand Down Expand Up @@ -330,7 +332,7 @@ class heterogeneous_iterator
return static_cast<difference_type>(this->__ptr_ - __other.__ptr_);
}

#ifndef _CCCL_DOXYGEN_INVOKED // Do not document
# ifndef _CCCL_DOXYGEN_INVOKED // Do not document
//! @brief Equality comparison between two heterogeneous_iterator
//! @param __lhs A heterogeneous_iterator.
//! @param __rhs Another heterogeneous_iterator.
Expand All @@ -340,7 +342,7 @@ class heterogeneous_iterator
{
return __lhs.__ptr_ == __rhs.__ptr_;
}
# if _CCCL_STD_VER <= 2017
# if _CCCL_STD_VER <= 2017
//! @brief Inequality comparison between two heterogeneous_iterator
//! @param __lhs A heterogeneous_iterator.
//! @param __rhs Another heterogeneous_iterator.
Expand All @@ -350,15 +352,15 @@ class heterogeneous_iterator
{
return __lhs.__ptr_ != __rhs.__ptr_;
}
# endif // _CCCL_STD_VER <= 2017
# endif // _CCCL_STD_VER <= 2017

# if _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
# if _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
[[nodiscard]] _CCCL_API friend constexpr ::cuda::std::strong_ordering
operator<=>(const heterogeneous_iterator& __lhs, const heterogeneous_iterator& __rhs) noexcept
{
return __lhs.__ptr_ <=> __rhs.__ptr_;
}
# else // ^^^ _LIBCUDACXX_HAS_SPACESHIP_OPERATOR() ^^^ / vvv !_LIBCUDACXX_HAS_SPACESHIP_OPERATOR() vvv
# else // ^^^ _LIBCUDACXX_HAS_SPACESHIP_OPERATOR() ^^^ / vvv !_LIBCUDACXX_HAS_SPACESHIP_OPERATOR() vvv
//! @brief Less than relation between two heterogeneous_iterator
//! @param __lhs A heterogeneous_iterator.
//! @param __rhs Another heterogeneous_iterator.
Expand Down Expand Up @@ -399,8 +401,8 @@ class heterogeneous_iterator
{
return __lhs.__ptr_ >= __rhs.__ptr_;
}
# endif // !_LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
#endif // _CCCL_DOXYGEN_INVOKED
# endif // !_LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
# endif // _CCCL_DOXYGEN_INVOKED

_CCCL_API constexpr pointer __unwrap() const noexcept
{
Expand Down Expand Up @@ -431,6 +433,8 @@ struct pointer_traits<::cuda::heterogeneous_iterator<_Tp, _Properties...>>

_CCCL_END_NAMESPACE_CUDA_STD

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

#endif // _CCCL_HAS_CTK()

#endif //__CUDAX__CONTAINERS_HETEROGENEOUS_ITERATOR_CUH
36 changes: 20 additions & 16 deletions libcudacxx/include/cuda/__container/uninitialized_async_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@
# pragma system_header
#endif // no system header

#include <cuda/__memory_resource/any_resource.h>
#include <cuda/__memory_resource/properties.h>
#include <cuda/__stream/stream_ref.h>
#include <cuda/std/__memory/addressof.h>
#include <cuda/std/__memory/align.h>
#include <cuda/std/__new/launder.h>
#include <cuda/std/__type_traits/type_set.h>
#include <cuda/std/__utility/exchange.h>
#include <cuda/std/__utility/move.h>
#include <cuda/std/__utility/swap.h>
#include <cuda/std/span>

#include <cuda/std/__cccl/prologue.h>
#if _CCCL_HAS_CTK()

# include <cuda/__memory_resource/any_resource.h>
# include <cuda/__memory_resource/properties.h>
# include <cuda/__stream/stream_ref.h>
# include <cuda/std/__memory/addressof.h>
# include <cuda/std/__memory/align.h>
# include <cuda/std/__new/launder.h>
# include <cuda/std/__type_traits/type_set.h>
# include <cuda/std/__utility/exchange.h>
# include <cuda/std/__utility/move.h>
# include <cuda/std/__utility/swap.h>
# include <cuda/std/span>

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

//! @file
//! The \c __uninitialized_async_buffer class provides a typed buffer allocated
Expand Down Expand Up @@ -138,7 +140,7 @@ class __uninitialized_async_buffer
return {__self.__get_data(), __self.size()};
}

#ifndef _CCCL_DOXYGEN_INVOKED
# ifndef _CCCL_DOXYGEN_INVOKED
// This is needed to ensure that we do not do a deep copy in
// __replace_allocation
struct __fake_resource_ref
Expand Down Expand Up @@ -179,7 +181,7 @@ class __uninitialized_async_buffer
_CCCL_REQUIRES(::cuda::std::__is_included_in_v<_Property, _Properties...>)
_CCCL_HIDE_FROM_ABI friend constexpr void get_property(const __fake_resource_ref&, _Property) noexcept {}
};
#endif // _CCCL_DOXYGEN_INVOKED
# endif // _CCCL_DOXYGEN_INVOKED

public:
using value_type = _Tp;
Expand Down Expand Up @@ -411,6 +413,8 @@ template <class _Tp>
using uninitialized_async_device_buffer = __uninitialized_async_buffer<_Tp, ::cuda::mr::device_accessible>;
_CCCL_END_NAMESPACE_CUDA

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

#endif // _CCCL_HAS_CTK()

#endif //__CUDAX__CONTAINERS_UNINITIALIZED_ASYNC_BUFFER_H
Loading
Loading