forked from tsai/mathnet-numerics
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
2.5 KiB
120 lines
2.5 KiB
#include <stdio.h>
|
|
|
|
#include "wrapper_cuda.h"
|
|
#include "cuda_runtime.h"
|
|
#include "cublas_v2.h"
|
|
#include "cusolverDn.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
/*
|
|
Capability is supported if >0
|
|
|
|
Actual number can be increased over time to indicate
|
|
extensions/revisions (that do not break compatibility)
|
|
*/
|
|
DLLEXPORT int query_capability(const int capability)
|
|
{
|
|
int count;
|
|
int device;
|
|
cudaDeviceProp prop;
|
|
|
|
switch (capability)
|
|
{
|
|
|
|
// SANITY CHECKS
|
|
case 0: return 0;
|
|
case 1: return -1;
|
|
|
|
// PLATFORM
|
|
case 8:
|
|
#ifdef _M_IX86
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case 9:
|
|
#ifdef _M_X64
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case 10:
|
|
#ifdef _M_IA64
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
|
|
// COMMON/SHARED
|
|
case 64:
|
|
if (cudaGetDeviceCount(&count))
|
|
return 0;
|
|
|
|
if (count == 0)
|
|
return 0;
|
|
|
|
if (cudaGetDevice(&device))
|
|
return 0;
|
|
|
|
if (cudaGetDeviceProperties(&prop, device))
|
|
return 0;
|
|
|
|
return prop.major;
|
|
|
|
// LINEAR ALGEBRA
|
|
case 128:
|
|
if (cudaGetDeviceCount(&count))
|
|
return 0;
|
|
|
|
if (count == 0)
|
|
return 0;
|
|
|
|
if (cudaGetDevice(&device))
|
|
return 0;
|
|
|
|
if (cudaGetDeviceProperties(&prop, device))
|
|
return 0;
|
|
|
|
return prop.major >= 2;
|
|
|
|
// OPTIMIZATION
|
|
case 256: return 0; // basic optimization
|
|
|
|
// FFT
|
|
case 384: return 0; // basic FFT
|
|
|
|
default: return 0; // unknown or not supported
|
|
|
|
}
|
|
}
|
|
|
|
DLLEXPORT CudaResults createBLASHandle(cublasHandle_t *blasHandle){
|
|
CudaResults ret = { cudaError_t::cudaSuccess, cublasStatus_t::CUBLAS_STATUS_SUCCESS, cusolverStatus_t::CUSOLVER_STATUS_SUCCESS };
|
|
ret.blasStatus = cublasCreate(blasHandle);
|
|
return ret;
|
|
}
|
|
|
|
DLLEXPORT CudaResults destroyBLASHandle(cublasHandle_t blasHandle){
|
|
CudaResults ret = { cudaError_t::cudaSuccess, cublasStatus_t::CUBLAS_STATUS_SUCCESS, cusolverStatus_t::CUSOLVER_STATUS_SUCCESS };
|
|
ret.blasStatus = cublasDestroy(blasHandle);
|
|
return ret;
|
|
}
|
|
|
|
DLLEXPORT CudaResults createSolverHandle(cusolverDnHandle_t *solverHandle){
|
|
CudaResults ret = { cudaError_t::cudaSuccess, cublasStatus_t::CUBLAS_STATUS_SUCCESS, cusolverStatus_t::CUSOLVER_STATUS_SUCCESS };
|
|
ret.solverStatus = cusolverDnCreate(solverHandle);
|
|
return ret;
|
|
}
|
|
|
|
DLLEXPORT CudaResults destroySolverHandle(cusolverDnHandle_t solverHandle){
|
|
CudaResults ret = { cudaError_t::cudaSuccess, cublasStatus_t::CUBLAS_STATUS_SUCCESS, cusolverStatus_t::CUSOLVER_STATUS_SUCCESS };
|
|
ret.solverStatus = cusolverDnDestroy(solverHandle);
|
|
return ret;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|