diff --git a/include/ck/host_utility/hip_check_error.hpp b/include/ck/host_utility/hip_check_error.hpp index af7bebd9d6..3e44faecb6 100644 --- a/include/ck/host_utility/hip_check_error.hpp +++ b/include/ck/host_utility/hip_check_error.hpp @@ -3,8 +3,10 @@ #pragma once +#include #include +// To be removed, which really does not tell the location of failed HIP functional call inline void hip_check_error(hipError_t x) { if(x != hipSuccess) @@ -15,3 +17,16 @@ inline void hip_check_error(hipError_t x) throw std::runtime_error(ss.str()); } } + +#define HIP_CHECK_ERROR(retval_or_funcall) \ + do \ + { \ + hipError_t _tmpVal = retval_or_funcall; \ + if(_tmpVal != hipSuccess) \ + { \ + std::ostringstream ostr; \ + ostr << "HIP Function Failed (" << __FILE__ << "," << __LINE__ << ") " \ + << hipGetErrorString(_tmpVal); \ + throw std::runtime_error(ostr.str()); \ + } \ + } while(0) diff --git a/include/ck/tensor_operation/gpu/device/impl/device_elementwise_impl.hpp b/include/ck/tensor_operation/gpu/device/impl/device_elementwise_impl.hpp index e203468c61..37867f1eaa 100644 --- a/include/ck/tensor_operation/gpu/device/impl/device_elementwise_impl.hpp +++ b/include/ck/tensor_operation/gpu/device/impl/device_elementwise_impl.hpp @@ -296,6 +296,28 @@ struct DeviceElementwiseImpl { return std::make_unique(); }; + + std::string GetTypeString() const override + { + auto str = std::stringstream(); + + // clang-format off + str << "DeviceElementwiseImpl<" ; + str << "NumDim_" << NumDim << ","; + str << "MPerThread_" << MPerThread << ","; + + str << "InScalarPerVector"; + static_for<0, InScalarPerVectorSeq::Size(), 1>{}([&](auto i) { str << "_" << InScalarPerVectorSeq::At(i).value; }); + str << ","; + str << "OutScalarPerVector"; + static_for<0, OutScalarPerVectorSeq::Size(), 1>{}([&](auto i) { str << "_" << OutScalarPerVectorSeq::At(i).value; }); + + str << ">"; + // clang-format on + + return str.str(); + } + }; // namespace device } // namespace device diff --git a/library/include/ck/library/utility/host_common_util.hpp b/library/include/ck/library/utility/host_common_util.hpp index 20a8f234db..16d6e2233a 100644 --- a/library/include/ck/library/utility/host_common_util.hpp +++ b/library/include/ck/library/utility/host_common_util.hpp @@ -22,7 +22,7 @@ static inline void dumpBufferToFile(const char* fileName, T* data, size_t dataNu std::ofstream outFile(fileName, std::ios::binary); if(outFile) { - outFile.write(reinterpret_cast(data), dataNumItems * sizeof(T)); + outFile.write(reinterpret_cast(data), dataNumItems * sizeof(T)); outFile.close(); std::cout << "Write output to file " << fileName << std::endl; } diff --git a/library/include/ck/library/utility/host_tensor_generator.hpp b/library/include/ck/library/utility/host_tensor_generator.hpp index 6b531c4c6f..6fd7ed8aa8 100644 --- a/library/include/ck/library/utility/host_tensor_generator.hpp +++ b/library/include/ck/library/utility/host_tensor_generator.hpp @@ -200,10 +200,11 @@ struct GeneratorTensor_3 template struct GeneratorTensor_4 { - std::default_random_engine generator; + std::mt19937 generator; std::normal_distribution distribution; - GeneratorTensor_4(float mean, float stddev) : generator(1), distribution(mean, stddev){}; + GeneratorTensor_4(float mean, float stddev, unsigned int seed = 1) + : generator(seed), distribution(mean, stddev){}; template T operator()(Is...)