Resolved errors due to hipCtxXXX APIs

Change-Id: Iffac0095c4352864eca622ea318d2291571b5153
Этот коммит содержится в:
Rahul Garg
2016-08-26 15:32:49 +05:30
родитель da80bf6326
Коммит 77991293ba
+47 -31
Просмотреть файл
@@ -22,7 +22,7 @@ THE SOFTWARE.
#pragma once
#include <cuda_runtime_api.h>
#include <cuda.h>
#ifdef __cplusplus
extern "C" {
@@ -60,6 +60,10 @@ hipMemcpyHostToHost
typedef cudaEvent_t hipEvent_t;
typedef cudaStream_t hipStream_t;
typedef CUcontext hipCtx_t;
typedef CUsharedconfig hipSharedMemConfig;
typedef CUfunc_cache hipFuncCache;
typedef CUdevice hipDevice_t;
//typedef cudaChannelFormatDesc hipChannelFormatDesc;
#define hipChannelFormatDesc cudaChannelFormatDesc
@@ -85,6 +89,18 @@ switch(cuError) {
};
}
inline static hipError_t hipCUResultTohipError(CUresult cuError) { //TODO Populate further
switch(cuError) {
case CUDA_SUCCESS : return hipSuccess;
case CUDA_ERROR_OUT_OF_MEMORY : return hipErrorMemoryAllocation ;
case CUDA_ERROR_INVALID_VALUE : return hipErrorInvalidValue ;
case CUDA_ERROR_INVALID_DEVICE : return hipErrorInvalidDevice ;
case CUDA_ERROR_DEINITIALIZED : return hipErrorInitializationError ;
case CUDA_ERROR_NO_DEVICE : return hipErrorNoDevice ;
default : return hipErrorUnknown; // Note - translated error.
};
}
// TODO match the error enum names of hip and cuda
inline static cudaError_t hipErrorToCudaError(hipError_t hError) {
switch(hError) {
@@ -347,20 +363,6 @@ inline static hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t att
return hipCUDAErrorTohipError(cerror);
}
template<class T>
inline static hipError_t hipOccupancyMaxPotentialBlockSize(
int *minGridSize,
int *blockSize,
T func,
size_t dynamicSMemSize = 0,
int blockSizeLimit = 0,
unsigned int flags = 0
){
cudaError_t cerror;
cerror = cudaOccupancyMaxPotentialBlockSize(minGridSize, blockSize, func, dynamicSMemSize, blockSizeLimit, flags);
return hipCUDAErrorTohipError(cerror);
}
inline static hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(
int *numBlocks,
const void* func,
@@ -476,12 +478,12 @@ inline static hipError_t hipDeviceEnablePeerAccess ( int peerDevice, unsigned
inline static hipError_t hipCtxDisablePeerAccess ( hipCtx_t peerCtx )
{
return hipCUDAErrorTohipError(cudaCtxDisablePeerAccess ( peerCtx ));
return hipCUResultTohipError(cuCtxDisablePeerAccess ( peerCtx ));
}
inline static hipError_t hipCtxEnablePeerAccess ( hipCtx_t peerCtx, unsigned int flags )
{
return hipCUDAErrorTohipError(cudaCtxEnablePeerAccess ( peerCtx, flags ));
return hipCUResultTohipError(cuCtxEnablePeerAccess ( peerCtx, flags ));
}
inline static hipError_t hipMemcpyPeer ( void* dst, int dstDevice, const void* src, int srcDevice, size_t count )
@@ -511,72 +513,72 @@ inline static hipError_t hipEventQuery(hipEvent_t event)
inline static hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device)
{
return hipCUDAErrorTohipError(cuCtxCreate ( ctx,flags,device ));
return hipCUResultTohipError(cuCtxCreate ( ctx,flags,device ));
}
inline static hipError_t hipCtxDestroy(hipCtx_t ctx)
{
return hipCUDAErrorTohipError(cuCtxDestroy ( ctx ));
return hipCUResultTohipError(cuCtxDestroy ( ctx ));
}
inline static hipError_t hipCtxPopCurrent(hipCtx_t* ctx)
{
return hipCUDAErrorTohipError(cuCtxPopCurrent ( ctx ));
return hipCUResultTohipError(cuCtxPopCurrent ( ctx ));
}
inline static hipError_t hipCtxPushCurrent(hipCtx_t ctx)
{
return hipCUDAErrorTohipError(cuCtxPushCurrent ( ctx ));
return hipCUResultTohipError(cuCtxPushCurrent ( ctx ));
}
inline static hipError_t hipCtxSetCurrent(hipCtx_t ctx)
{
return hipCUDAErrorTohipError(cuCtxSetCurrent ( ctx ));
return hipCUResultTohipError(cuCtxSetCurrent ( ctx ));
}
inline static hipError_t hipCtxGetCurrent(hipCtx_t* ctx)
{
return hipCUDAErrorTohipError(cuCtxGetCurrent ( ctx ));
return hipCUResultTohipError(cuCtxGetCurrent ( ctx ));
}
inline static hipError_t hipCtxGetDevice(hipDevice_t *device)
{
return hipCUDAErrorTohipError(cuCtxGetDevice ( device ));
return hipCUResultTohipError(cuCtxGetDevice ( device ));
}
inline static hipError_t hipCtxGetApiVersion (hipCtx_t ctx,int *apiVersion)
{
return hipCUDAErrorTohipError(cuCtxGetApiVersion ( ctx,apiVersion ));
return hipCUResultTohipError(cuCtxGetApiVersion ( ctx,(unsigned int*)apiVersion ));
}
inline static hipError_t hipCtxGetCacheConfig ( hipFuncCache *cacheConfig )
{
return hipCUDAErrorTohipError(cuCtxGetCacheConfig ( cacheConfig ));
return hipCUResultTohipError(cuCtxGetCacheConfig ( cacheConfig ));
}
inline static hipError_t hipCtxSetCacheConfig ( hipFuncCache cacheConfig )
{
return hipCUDAErrorTohipError(cuCtxSetCacheConfig ( cacheConfig ));
return hipCUResultTohipError(cuCtxSetCacheConfig ( cacheConfig ));
}
inline static hipError_t hipCtxSetSharedMemConfig ( hipSharedMemConfig config )
{
return hipCUDAErrorTohipError(cuCtxSetSharedMemConfig ( config ));
return hipCUResultTohipError(cuCtxSetSharedMemConfig ( config ));
}
inline static hipError_t hipCtxGetSharedMemConfig ( hipSharedMemConfig * pConfig )
{
return hipCUDAErrorTohipError(cuCtxGetSharedMemConfig ( pConfig ));
return hipCUResultTohipError(cuCtxGetSharedMemConfig ( pConfig ));
}
inline static hipError_t hipCtxSynchronize ( void )
{
return hipCUDAErrorTohipError(cuCtxSynchronize ( void ));
return hipCUResultTohipError(cuCtxSynchronize ( ));
}
inline static hipError_t hipCtxGetFlags ( unsigned int* flags )
{
return hipCUDAErrorTohipError(cuCtxGetFlags ( flags ));
return hipCUResultTohipError(cuCtxGetFlags ( flags ));
}
#ifdef __cplusplus
@@ -585,6 +587,20 @@ inline static hipError_t hipCtxGetFlags ( unsigned int* flags )
#ifdef __CUDACC__
template<class T>
inline static hipError_t hipOccupancyMaxPotentialBlockSize(
int *minGridSize,
int *blockSize,
T func,
size_t dynamicSMemSize = 0,
int blockSizeLimit = 0,
unsigned int flags = 0
){
cudaError_t cerror;
cerror = cudaOccupancyMaxPotentialBlockSize(minGridSize, blockSize, func, dynamicSMemSize, blockSizeLimit, flags);
return hipCUDAErrorTohipError(cerror);
}
template <class T, int dim, enum cudaTextureReadMode readMode>
inline static hipError_t hipBindTexture(size_t *offset,
const struct texture<T, dim, readMode> &tex,