diff --git a/include/hcc_detail/hip_hcc.h b/include/hcc_detail/hip_hcc.h index e79ba9e1dc..a3f9c73a13 100644 --- a/include/hcc_detail/hip_hcc.h +++ b/include/hcc_detail/hip_hcc.h @@ -466,6 +466,17 @@ inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) return os; } +inline std::ostream & operator<<(std::ostream& os, const dim3& s) +{ + os << '{'; + os << s.x; + os << ','; + os << s.y; + os << ','; + os << s.z; + os << '}'; + return os; +} //---- // Internal event structure: diff --git a/include/hcc_detail/hip_runtime_api.h b/include/hcc_detail/hip_runtime_api.h index daf737563e..1ee7d70ef5 100644 --- a/include/hcc_detail/hip_runtime_api.h +++ b/include/hcc_detail/hip_runtime_api.h @@ -121,7 +121,6 @@ typedef struct dim3 { } dim3; - /** * Memory copy types * diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 86e8563272..f16ae715c1 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -61,7 +61,7 @@ hipError_t hipGetDeviceCount(int *count) */ hipError_t hipDeviceSetCacheConfig ( hipFuncCache cacheConfig ) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(cacheConfig); // Nop, AMD does not support variable cache configs. @@ -75,7 +75,7 @@ hipError_t hipDeviceSetCacheConfig ( hipFuncCache cacheConfig ) */ hipError_t hipDeviceGetCacheConfig ( hipFuncCache *cacheConfig ) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(cacheConfig); *cacheConfig = hipFuncCachePreferNone; @@ -89,7 +89,7 @@ hipError_t hipDeviceGetCacheConfig ( hipFuncCache *cacheConfig ) */ hipError_t hipFuncSetCacheConfig ( hipFuncCache cacheConfig ) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(cacheConfig); // Nop, AMD does not support variable cache configs. @@ -104,7 +104,7 @@ hipError_t hipFuncSetCacheConfig ( hipFuncCache cacheConfig ) */ hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig config ) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(config); // Nop, AMD does not support variable shared mem configs. @@ -119,7 +119,7 @@ hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig config ) */ hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig * pConfig ) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(pConfig); *pConfig = hipSharedMemBankSizeFourByte; @@ -184,7 +184,7 @@ hipError_t hipDeviceReset(void) */ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(attr, device); hipError_t e = hipSuccess; diff --git a/src/hip_event.cpp b/src/hip_event.cpp index 983b190644..1514fc5868 100644 --- a/src/hip_event.cpp +++ b/src/hip_event.cpp @@ -69,7 +69,7 @@ hipError_t hipEventCreate(hipEvent_t* event) //--- hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(event, stream); ihipEvent_t *eh = event._handle; if (eh && eh->_state != hipEventStatusUnitialized) { @@ -104,7 +104,7 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) //--- hipError_t hipEventDestroy(hipEvent_t event) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(event); event._handle->_state = hipEventStatusUnitialized; @@ -119,7 +119,7 @@ hipError_t hipEventDestroy(hipEvent_t event) //--- hipError_t hipEventSynchronize(hipEvent_t event) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(event); ihipEvent_t *eh = event._handle; @@ -148,7 +148,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) //--- hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(ms, start, stop); ihipEvent_t *start_eh = start._handle; ihipEvent_t *stop_eh = stop._handle; @@ -193,7 +193,7 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) //--- hipError_t hipEventQuery(hipEvent_t event) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(event); ihipEvent_t *eh = event._handle; diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index 6334b6004d..5bdbefcdfe 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -1113,7 +1113,7 @@ void decKernelCnt(){ // Allows runtime to track some information about the stream. hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(stream, grid, block, lp); stream = ihipSyncAndResolveStream(stream); #if USE_GRID_LAUNCH_20 lp->grid_dim.x = grid.x; @@ -1143,7 +1143,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_ } hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(stream, grid, block, lp); stream = ihipSyncAndResolveStream(stream); #if USE_GRID_LAUNCH_20 lp->grid_dim.x = grid; @@ -1174,7 +1174,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, gri hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(stream, grid, block, lp); stream = ihipSyncAndResolveStream(stream); #if USE_GRID_LAUNCH_20 lp->grid_dim.x = grid.x; @@ -1205,7 +1205,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, gri hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(stream, grid, block, lp); stream = ihipSyncAndResolveStream(stream); #if USE_GRID_LAUNCH_20 lp->grid_dim.x = grid; @@ -1253,8 +1253,8 @@ void ihipPostLaunchKernel(hipStream_t stream, grid_launch_parm &lp) // HIP API Implementation // // Implementor notes: -// _ All functions should call ihipInit as first action: -// std::call_once(hip_initialized, ihipInit); +// _ All functions should call HIP_INIT_API as first action: +// HIP_INIT_API(); // // - ALl functions should use ihipLogStatus to return error code (not return error directly). //================================================================================================= @@ -1629,7 +1629,7 @@ void ihipStream_t::copyAsync(void* dst, const void* src, size_t sizeBytes, unsig //--- hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(deviceId, acc); ihipDevice_t *d = ihipGetDevice(deviceId); hipError_t err; @@ -1649,7 +1649,7 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc) //--- hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(stream, av); if (stream == hipStreamNull ) { ihipDevice_t *device = ihipGetTlsDefaultDevice(); diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 95429b26e6..d458256fdf 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -36,7 +36,7 @@ THE SOFTWARE. */ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(attributes, ptr); hipError_t e = hipSuccess; @@ -85,7 +85,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) */ hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsigned flags) { - std::call_once(hip_initialized, ihipInit); + HIP_INIT_API(devicePointer, hostPointer, flags); hipError_t e = hipSuccess;