diff --git a/External/HIP/CMakeLists.txt b/External/HIP/CMakeLists.txt --- a/External/HIP/CMakeLists.txt +++ b/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 diff --git a/External/HIP/stdlib_functional.hip b/External/HIP/stdlib_functional.hip new file mode 100644 --- /dev/null +++ b/External/HIP/stdlib_functional.hip @@ -0,0 +1,27 @@ +#include +#include +#include + +#if !__HIP_USE_LIBCPP +#error "This test requests -stdlib=libc++" +#endif // __HIP_USE_LIBCPP + +__managed__ int x; + +__global__ void kern() { + auto plus = std::plus(); + 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; +} diff --git a/External/HIP/stdlib_functional.reference_output b/External/HIP/stdlib_functional.reference_output new file mode 100644 --- /dev/null +++ b/External/HIP/stdlib_functional.reference_output @@ -0,0 +1,2 @@ +PASSED! +exit 0