NVCC improvements.
- Complete translation tables for cudaError <-> hipError_t.
- Remove some odd errors that were not correctly translated or not used.
- Add HIPCHECK_API to test infrastructure. Used for negative testing
an API ; if a mismatch occurs it shows the expected return error
code. Can also print a warning rather than error.
- Enable hipMemoryAllocate on NV system, and review error coded.
- Add hipErrorName to nvcc.
Change-Id: I680427dcf32a5796d5913cf9e7f3b4c6f6b91599
Conflicts:
tests/src/CMakeLists.txt
Bug fixes and improved docs for hipFree and hipHostFree.
- Passing NULL pointer initialized runtime and return hipSuccess
(not an error like before).
- add negative test for this. (hipMemoryAllocate, improved)
- Match NVCC errors for invalid pointers, add to test.
- Update hipFree and hipHostFree docs.
- hipGetDevicePointer always set *devicePointer=NULL, even for
invalid flags.
- Gate shared memory usage on specific HCC work-week.
Change-Id: I533b4fd3280a3d6cdbf05eb768976f0c7506c012
このコミットが含まれているのは:
@@ -764,28 +764,32 @@ hipError_t hipHostUnregister(void* hostPtr) ;
|
||||
/**
|
||||
* @brief Free memory allocated by the hcc hip memory allocation API.
|
||||
* This API performs an implicit hipDeviceSynchronize() call.
|
||||
* If pointer is NULL, the hip runtime is initialized and hipSuccess is returned.
|
||||
*
|
||||
* @param[in] ptr Pointer to memory to be freed
|
||||
* @return #hipSuccess, #hipErrorMemoryFree
|
||||
* @return #hipSuccess
|
||||
* @return #hipErrorInvalidDevicePointer (if pointer is invalid, including host pointers allocated with hipHostMalloc)
|
||||
*/
|
||||
hipError_t hipFree(void* ptr);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated by the hcc hip host memory allocation API
|
||||
* @brief Free memory allocated by the hcc hip host memory allocation API. [Deprecated.]
|
||||
*
|
||||
* @param[in] ptr Pointer to memory to be freed
|
||||
* @return #hipSuccess, #hipErrorMemoryFree
|
||||
* @see hipHostFree
|
||||
*/
|
||||
hipError_t hipFreeHost(void* ptr) __attribute__((deprecated("use hipHostFree instead"))) ;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated by the hcc hip host memory allocation API
|
||||
* This API performs an implicit hipDeviceSynchronize() call.
|
||||
* If pointer is NULL, the hip runtime is initialized and hipSuccess is returned.
|
||||
*
|
||||
* @param[in] ptr Pointer to memory to be freed
|
||||
* @return #hipSuccess, #hipErrorMemoryFree
|
||||
* @return #hipSuccess,
|
||||
* #hipErrorInvalidValue (if pointer is invalid, including device pointers allocated with hipMalloc)
|
||||
*/
|
||||
hipError_t hipHostFree(void* ptr);
|
||||
|
||||
|
||||
@@ -139,12 +139,12 @@ typedef struct hipPointerAttribute_t {
|
||||
* @ingroup Enumerations
|
||||
*/
|
||||
// Developer note - when updating these, update the hipErrorName and hipErrorString functions in NVCC and HCC paths
|
||||
// Also update the hipCUDAErrorTohipError function in NVCC path.
|
||||
|
||||
typedef enum hipError_t {
|
||||
hipSuccess = 0 ///< Successful completion.
|
||||
,hipErrorMemoryAllocation ///< Memory allocation error.
|
||||
,hipErrorMemoryFree ///< Memory free error.
|
||||
,hipErrorUnknownSymbol ///< Unknown symbol.
|
||||
,hipErrorOutOfResources ///< Out of resources error.
|
||||
,hipErrorLaunchOutOfResources ///< Out of resources error.
|
||||
,hipErrorInvalidValue ///< One or more of the parameters passed to the API call is NULL or not in an acceptable range.
|
||||
,hipErrorInvalidResourceHandle ///< Resource handle (hipEvent_t or hipStream_t) invalid.
|
||||
,hipErrorInvalidDevice ///< DeviceID must be in range 0...#compute-devices.
|
||||
|
||||
@@ -65,29 +65,50 @@ typedef cudaStream_t hipStream_t;
|
||||
|
||||
inline static hipError_t hipCUDAErrorTohipError(cudaError_t cuError) {
|
||||
switch(cuError) {
|
||||
case cudaSuccess:
|
||||
return hipSuccess;
|
||||
case cudaErrorMemoryAllocation:
|
||||
return hipErrorMemoryAllocation;
|
||||
case cudaErrorInvalidDevicePointer:
|
||||
case cudaErrorInitializationError:
|
||||
return hipErrorMemoryFree;
|
||||
default:
|
||||
return hipErrorUnknown;
|
||||
}
|
||||
case cudaSuccess : return hipSuccess;
|
||||
case cudaErrorMemoryAllocation : return hipErrorMemoryAllocation ;
|
||||
case cudaErrorLaunchOutOfResources : return hipErrorLaunchOutOfResources ;
|
||||
case cudaErrorInvalidValue : return hipErrorInvalidValue ;
|
||||
case cudaErrorInvalidResourceHandle : return hipErrorInvalidResourceHandle ;
|
||||
case cudaErrorInvalidDevice : return hipErrorInvalidDevice ;
|
||||
case cudaErrorInvalidMemcpyDirection : return hipErrorInvalidMemcpyDirection ;
|
||||
case cudaErrorInvalidDevicePointer : return hipErrorInvalidDevicePointer ;
|
||||
case cudaErrorInitializationError : return hipErrorInitializationError ;
|
||||
case cudaErrorNoDevice : return hipErrorNoDevice ;
|
||||
case cudaErrorNotReady : return hipErrorNotReady ;
|
||||
case cudaErrorUnknown : return hipErrorUnknown ;
|
||||
case cudaErrorPeerAccessNotEnabled : return hipErrorPeerAccessNotEnabled ;
|
||||
case cudaErrorPeerAccessAlreadyEnabled : return hipErrorPeerAccessAlreadyEnabled ;
|
||||
case cudaErrorHostMemoryAlreadyRegistered : return hipErrorHostMemoryAlreadyRegistered ;
|
||||
case cudaErrorHostMemoryNotRegistered : return hipErrorHostMemoryNotRegistered ;
|
||||
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) {
|
||||
case hipSuccess:
|
||||
return cudaSuccess;
|
||||
case hipErrorMemoryAllocation:
|
||||
return cudaErrorMemoryAllocation;
|
||||
case hipErrorMemoryFree:
|
||||
return cudaErrorInitializationError;
|
||||
default:
|
||||
return cudaErrorUnknown;
|
||||
}
|
||||
case hipSuccess : return cudaSuccess;
|
||||
case hipErrorMemoryAllocation : return cudaErrorMemoryAllocation ;
|
||||
case hipErrorLaunchOutOfResources : return cudaErrorLaunchOutOfResources ;
|
||||
case hipErrorInvalidValue : return cudaErrorInvalidValue ;
|
||||
case hipErrorInvalidResourceHandle : return cudaErrorInvalidResourceHandle ;
|
||||
case hipErrorInvalidDevice : return cudaErrorInvalidDevice ;
|
||||
case hipErrorInvalidMemcpyDirection : return cudaErrorInvalidMemcpyDirection ;
|
||||
case hipErrorInvalidDevicePointer : return cudaErrorInvalidDevicePointer ;
|
||||
case hipErrorInitializationError : return cudaErrorInitializationError ;
|
||||
case hipErrorNoDevice : return cudaErrorNoDevice ;
|
||||
case hipErrorNotReady : return cudaErrorNotReady ;
|
||||
case hipErrorUnknown : return cudaErrorUnknown ;
|
||||
case hipErrorPeerAccessNotEnabled : return cudaErrorPeerAccessNotEnabled ;
|
||||
case hipErrorPeerAccessAlreadyEnabled : return cudaErrorPeerAccessAlreadyEnabled ;
|
||||
case hipErrorRuntimeMemory : return cudaErrorUnknown ; // Does not exist in CUDA
|
||||
case hipErrorRuntimeOther : return cudaErrorUnknown ; // Does not exist in CUDA
|
||||
case hipErrorHostMemoryAlreadyRegistered : return cudaErrorHostMemoryAlreadyRegistered ;
|
||||
case hipErrorHostMemoryNotRegistered : return cudaErrorHostMemoryNotRegistered ;
|
||||
case hipErrorTbd : return cudaErrorUnknown; // Note - translated error.
|
||||
default : return cudaErrorUnknown; // Note - translated error.
|
||||
}
|
||||
}
|
||||
|
||||
inline static cudaMemcpyKind hipMemcpyKindToCudaMemcpyKind(hipMemcpyKind kind) {
|
||||
@@ -178,6 +199,10 @@ inline static const char* hipGetErrorString(hipError_t error){
|
||||
return cudaGetErrorString( hipErrorToCudaError(error) );
|
||||
}
|
||||
|
||||
inline static const char* hipGetErrorName(hipError_t error){
|
||||
return cudaGetErrorName( hipErrorToCudaError(error) );
|
||||
}
|
||||
|
||||
inline static hipError_t hipGetDeviceCount(int * count){
|
||||
return hipCUDAErrorTohipError(cudaGetDeviceCount(count));
|
||||
}
|
||||
@@ -329,7 +354,7 @@ inline static hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attribut
|
||||
case cudaMemoryTypeHost:
|
||||
attributes->memoryType = hipMemoryTypeHost; break;
|
||||
default:
|
||||
return hipErrorUnknownSymbol;
|
||||
return hipErrorUnknown;
|
||||
}
|
||||
attributes->device = cPA.device;
|
||||
attributes->devicePointer = cPA.devicePointer;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする