Ejemplo n.º 1
0
void CudaUtil::cublasClose(cublasHandle_t handle)
{
	cublasStatus_t status = cublasDestroy(handle);
	if (status != CUBLAS_STATUS_SUCCESS) {
		throw CudaException("CUBALS destroy error");
	}
}
Ejemplo n.º 2
0
void CudaUtil::checkCublasStatus(cublasStatus_t status, int line, const char* file)
{
	if (status != CUBLAS_STATUS_SUCCESS) {
		std::ostringstream os;
		os << "CUBLAS error, line " << line << ", in file " << file;
		throw CudaException(os.str());
	}
}
Ejemplo n.º 3
0
void CudaUtil::cudaCheckMemcpy(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, int line, const char* file)
{
	int error = cudaMemcpy(dst, src, count, kind);
    if (error != cudaSuccess) {
    	std::ostringstream os;
    	os << "cudaMemcpy returned error code " << error << ", line " << line << ", in file " << file;
    	throw CudaException(os.str());
    }
}
Ejemplo n.º 4
0
void CudaUtil::cudaCheckMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height, int line, const char* file)
{
	int error = cudaMallocPitch(ptr, pitch, width, height);
    if (error != cudaSuccess) {
    	std::ostringstream os;
    	os << "cudaMallocPitch returned error code " << error << ", line " << line << ", in file " << file;
    	throw CudaException(os.str());
    }
}
Ejemplo n.º 5
0
void CudaUtil::cudaCheckMalloc(void** ptr, size_t size, int line, const char* file)
{
	int error = cudaMalloc(ptr, size);
    if (error != cudaSuccess) {
    	std::ostringstream os;
    	os << "cudaMalloc returned error code " << error << ", line " << line << ", in file " << file;
    	throw CudaException(os.str());
    }
}
Ejemplo n.º 6
0
cublasHandle_t CudaUtil::cublasInit()
{
	cublasHandle_t handle;
	cublasStatus_t status = cublasCreate(&handle);
	if (status != CUBLAS_STATUS_SUCCESS) {
		throw CudaException("CUBALS initialisation error");
	}
	return handle;
}
Ejemplo n.º 7
0
void CudaUtil::cudaCheckFree(void* ptr, int line, const char* file)
{
	cudaError_t error = cudaFree(ptr);
	if (error != cudaSuccess) {
		std::ostringstream os;
		os << "cudaFree returned error code " << error << ", line " << line << ", in file " << file;
		throw CudaException(os.str());
	}
}
Ejemplo n.º 8
0
void CudaUtil::cublasCheckGetVector(int n, int elemSize, void* devicePtr, int incx, void* hostPtr, int incy, int line, const char* file)
{
	cublasStatus_t status = cublasGetVector(n, elemSize, devicePtr, incx, hostPtr, incy);
	if (status != CUBLAS_STATUS_SUCCESS) {
		std::ostringstream os;
		os << "CUBALS device read error, line " << line << ", in file " << file;
		throw CudaException(os.str());
	}
}
Ejemplo n.º 9
0
void CudaUtil::cudaCheckLastError(int line, const char* file)
{
	cudaError_t lauchSuccess = cudaGetLastError();
	if (lauchSuccess != cudaSuccess) {
		std::ostringstream os;
		os << "CUDA error " << cudaGetErrorString(lauchSuccess) << ", line " << line << ", in file " << file;
		throw CudaException(os.str());
	}
}
Ejemplo n.º 10
0
void CudaUtil::getDeviceProperties(int line, const char* file)
{
	int count;
	int error = cudaGetDeviceCount(&count);
	if (error != cudaSuccess) {
		std::ostringstream os;
		os << "cudaGetDeviceCount returned error code " << error << ", line " << line << ", in file " << file;
		throw CudaException(os.str());
	}
	std::cout << "Number of CUDA devices = " << count << std::endl;
	cudaDeviceProp prop;
	for (int i = 0; i < count; i++) {
		error = cudaGetDeviceProperties(&prop, i);
		if (error == cudaSuccess) {
			std::cout << "\tName: " << prop.name << std::endl;
			std::cout << "\tCompute capability: " << prop.major << "." << prop.minor << std::endl;
			// std::cout << "\tTotal Global Mem: " << prop.totalGlobalMem << std::endl;
		}
	}
}
Ejemplo n.º 11
0
	void GPUCodec::checkCudaStatus(cudaError_t cudaStatus)
	{
		if (cudaStatus != cudaSuccess)
			throw CudaException(cudaStatus);
	}