Replace printf
MODIFY
thrust/system/hip/detail/terminate.h
thrust/system/hip/detail/terminate.h
@@ -49,7 +49,10 @@ void THRUST_HIP_DEVICE_FUNCTION terminate()
void THRUST_HIP_FUNCTION terminate_with_message(const char* message)
{
- printf("%s\n", message);
+ THRUST_HIP_PRINTF("%s\n", message);
+#ifndef THRUST_HIP_PRINTF_ENABLED
+ THRUST_UNUSED_VAR(message);
+#endif
thrust::hip_rocprim::terminate();
}

MODIFY
thrust/system/hip/detail/util.h
thrust/system/hip/detail/util.h
#include <thrust/system/hip/error.h>
#include <thrust/system_error.h>
+// Enable if you want printf on device side
+// #define THRUST_HIP_PRINTF_ENABLED 1
+
+#ifdef THRUST_HIP_PRINTF_ENABLED
+ #define THRUST_HIP_PRINTF(text, ...) \
+ printf(text, ##__VA_ARGS__)
+#else
+ #define THRUST_HIP_PRINTF(text, ...)
+#endif
+
BEGIN_NS_THRUST
namespace hip_rocprim
{
@@ -135,7 +145,11 @@ static void __host__ __device__ throw_on_error(hipError_t status, char const* ms
#if __THRUST_HAS_HIPRT__
printf("Error after %s: %s\n", msg, hipGetErrorString(status));
#else
- printf("Error %d: %s \n", (int)status, msg);
+ THRUST_HIP_PRINTF("Error %d: %s \n", (int)status, msg);
+ #ifndef THRUST_HIP_PRINTF_ENABLED
+ THRUST_UNUSED_VAR(status);
+ THRUST_UNUSED_VAR(msg);
+ #endif
#endif
hip_rocprim::terminate();
#endif

Replace printf