[PATCH] D102508: [HIP] Add test libstd_functional
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 14 09:16:50 PDT 2021
yaxunl created this revision.
yaxunl added reviewers: tra, ashi1.
Herald added a subscriber: mgorny.
yaxunl requested review of this revision.
This patch adds a test for using <functional> in HIP device code.
Repository:
rT test-suite
https://reviews.llvm.org/D102508
Files:
External/HIP/CMakeLists.txt
External/HIP/stdlib_functional.hip
External/HIP/stdlib_functional.reference_output
Index: External/HIP/stdlib_functional.reference_output
===================================================================
--- /dev/null
+++ External/HIP/stdlib_functional.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/stdlib_functional.hip
===================================================================
--- /dev/null
+++ External/HIP/stdlib_functional.hip
@@ -0,0 +1,27 @@
+#include <hip/hip_runtime.h>
+#include <stdio.h>
+#include <functional>
+
+#if !__HIP_USE_LIBCPP
+#error "This test requests -stdlib=libc++"
+#endif // __HIP_USE_LIBCPP
+
+__managed__ int x;
+
+__global__ void kern() {
+ auto plus = std::plus<int>();
+ auto plus2 = std::bind(plus, std::placeholders::_1, 2);
+ x = plus2(x);
+}
+
+int main() {
+ kern<<<1,1>>>();
+ hipDeviceSynchronize();
+ if (x != 2) {
+ printf("FAILED!\n");
+ return 1;
+ }
+
+ printf("PASSED!\n");
+ return 0;
+}
Index: External/HIP/CMakeLists.txt
===================================================================
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
# Create targets for HIP tests that are part of the test suite.
macro(create_local_hip_tests VariantSuffix)
set(VariantOffload "hip")
+ # Set per-source compilation/link options
+ set_source_files_properties(stdlib_functional.hip PROPERTIES
+ COMPILE_FLAGS -stdlib=libc++)
# Add HIP tests to be added to hip-tests-simple
list(APPEND HIP_LOCAL_TESTS empty)
+ list(APPEND HIP_LOCAL_TESTS stdlib_functional)
list(APPEND HIP_LOCAL_TESTS saxpy)
foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
create_one_local_test(${_hip_test} ${_hip_test}.hip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102508.345459.patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210514/a0a987ae/attachment.bin>
More information about the cfe-commits
mailing list