[PATCH] D48037: [CUDA] Add tests to ensure that std::min/max can be called from __host__ __device__ functions.
Justin Lebar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 29 17:37:39 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336029: [CUDA] Add tests to ensure that std::min/max can be called from __host__… (authored by jlebar, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D48037
Files:
test-suite/trunk/External/CUDA/algorithm.cu
Index: test-suite/trunk/External/CUDA/algorithm.cu
===================================================================
--- test-suite/trunk/External/CUDA/algorithm.cu
+++ test-suite/trunk/External/CUDA/algorithm.cu
@@ -17,10 +17,16 @@
__device__ void min() {
assert(std::min(0, 1) == 0);
}
+__host__ __device__ void min_hd() {
+ assert(std::min(0, 1) == 0);
+}
__device__ void max() {
assert(std::max(0, 1) == 1);
}
+__host__ __device__ void max_hd() {
+ assert(std::max(0, 1) == 1);
+}
// Clang has device-side shims implementing std::min and std::max for scalars
// starting in C++11, but doesn't implement minimax or std::min/max on
@@ -39,10 +45,27 @@
#endif
}
+// Same tests as cpp14_tests, but from a host-device context.
+__host__ __device__ void cpp14_tests_hd() {
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
+ assert(std::greater<int>()(1, 0));
+ assert(std::min({5, 1, 10}) == 1);
+ assert(std::max({5, 1, 10}, std::less<int>()) == 10);
+
+ assert(std::minmax(1, 0).first == 0);
+ assert(std::minmax(1, 0).second == 1);
+ assert(std::minmax({0, 10, -10, 100}, std::less<int>()).first == -10);
+ assert(std::minmax({0, 10, -10, 100}, std::less<int>()).second == 100);
+#endif
+}
+
__global__ void kernel() {
min();
+ min_hd();
max();
+ max_hd();
cpp14_tests();
+ cpp14_tests_hd();
}
int main() {
@@ -52,6 +75,11 @@
printf("CUDA error %d\n", (int)err);
return 1;
}
+
+ min_hd();
+ max_hd();
+ cpp14_tests_hd();
+
printf("Success!\n");
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48037.153602.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180630/45bda689/attachment.bin>
More information about the cfe-commits
mailing list