|
@@ -1,15 +1,15 @@
|
|
|
-
|
|
|
-#include <stdexcept>
|
|
|
#include <cmath>
|
|
|
-#include <math.h>
|
|
|
#include <memory>
|
|
|
+#include <stdexcept>
|
|
|
|
|
|
-#include <hip/hip_runtime.h>
|
|
|
#include <hip/hip_fp16.h>
|
|
|
+#include <hip/hip_runtime.h>
|
|
|
+#include <math.h>
|
|
|
|
|
|
namespace {
|
|
|
-template<class T, class F>
|
|
|
-__global__ void global_entry_point(F f, T *out) {
|
|
|
+template <class T, class F>
|
|
|
+__global__ void global_entry_point(F f, T* out)
|
|
|
+{
|
|
|
*out = f();
|
|
|
}
|
|
|
|
|
@@ -23,7 +23,9 @@ bool verify(F f, T expected)
|
|
|
}
|
|
|
bool result = true;
|
|
|
hipLaunchKernelGGL(global_entry_point, 1, 1, 0, 0, f, gpu_T);
|
|
|
- result = hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost) == hipSuccess && result;
|
|
|
+ result = hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost) ==
|
|
|
+ hipSuccess &&
|
|
|
+ result;
|
|
|
result = hipFree(gpu_T) == hipSuccess && result;
|
|
|
result = *cpu_T == expected && result;
|
|
|
return result;
|
|
@@ -32,9 +34,9 @@ bool verify(F f, T expected)
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
{
|
|
|
- bool valid = verify([]__device__(){ return std::round(1.4f); }, 1.0f);
|
|
|
- valid &= verify([]__device__(){ return max<_Float16>(1.0f, 2.0f); }, 2.0f);
|
|
|
- valid &= verify([]__device__(){ return min<_Float16>(1.0f, 2.0f); }, 1.0f);
|
|
|
+ bool valid = verify([] __device__() { return std::round(1.4f); }, 1.0f);
|
|
|
+ valid &= verify([] __device__() { return max<_Float16>(1.0f, 2.0f); }, 2.0f);
|
|
|
+ valid &= verify([] __device__() { return min<_Float16>(1.0f, 2.0f); }, 1.0f);
|
|
|
|
|
|
if (valid) {
|
|
|
return 0;
|