Support use in CUDA device-side code#20
Open
eyalroz wants to merge 1 commit intotcbrindle:masterfrom
eyalroz:master
Open
Support use in CUDA device-side code#20eyalroz wants to merge 1 commit intotcbrindle:masterfrom eyalroz:master
eyalroz wants to merge 1 commit intotcbrindle:masterfrom
eyalroz:master
Conversation
tcbrindle
requested changes
Sep 12, 2019
Author
|
@tcbrindle : How about now? Also, even if you ok this - don't merge yet. |
tcbrindle
approved these changes
Sep 13, 2019
|
@eyalroz I had to make some changes to your tentative span to get it to compile with diff --git a/span.h b/span.h
index 380402b..41a20da 100644
--- a/span.h
+++ b/span.h
@@ -52,6 +52,11 @@
#define TCB_SPAN_CUDA_HOST_AND_DEVICE
#endif
+#ifdef __CUDA_ARCH__
+#define TCB_SPAN_NO_EXCEPTIONS
+#define TCB_SPAN_NO_CONTRACT_CHECKING
+#endif
+
#ifndef TCB_SPAN_NO_EXCEPTIONS
#include <cstdio>
#include <stdexcept>
@@ -169,7 +174,8 @@ using byte = unsigned char;
#define TCB_SPAN_NODISCARD
#endif
-TCB_SPAN_INLINE_VAR constexpr std::size_t dynamic_extent = -1;
+TCB_SPAN_INLINE_VAR constexpr std::size_t dynamic_extent =
+ static_cast<std::size_t>(-1);
template <typename ElementType, std::size_t Extent = dynamic_extent>
class span;
@@ -178,7 +184,7 @@ namespace detail {
template <typename E, std::size_t S>
struct span_storage {
- TCB_SPAN_CONSTEXPR span_storage() noexcept = default;
+ constexpr span_storage() noexcept = default;
TCB_SPAN_CONSTEXPR span_storage(E* ptr, std::size_t /*unused*/) noexcept
: ptr(ptr) {}
@@ -189,7 +195,7 @@ struct span_storage {
template <typename E>
struct span_storage<E, dynamic_extent> {
- TCB_SPAN_CONSTEXPR span_storage() noexcept = default;
+ constexpr span_storage() noexcept = default;
TCB_SPAN_CONSTEXPR span_storage(E* ptr, std::size_t size) noexcept
: ptr(ptr), size(size) {}
@@ -385,7 +391,7 @@ class span {
TCB_SPAN_CONSTEXPR span(const Container& cont)
: storage_(detail::data(cont), detail::size(cont)) {}
- TCB_SPAN_CONSTEXPR span(const span& other) noexcept = default;
+ constexpr span(const span& other) noexcept = default;
template <typename OtherElementType, std::size_t OtherExtent,
typename std::enable_if<
@@ -399,8 +405,7 @@ class span {
~span() noexcept = default;
- TCB_SPAN_CONSTEXPR_ASSIGN span& operator=(const span& other) noexcept =
- default;
+ constexpr span& operator=(const span& other) noexcept = default;
// [span.sub], span subviews
template <std::size_t Count> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TCB_CONSTEXPRmacro instead ofconstexpr, to hook our extra decorationsTCB_CONSTEXPRfunctions with__host__ __device__when compiling CUDA code.Notes:
spans are fully-constexpr.