cuda
This commit is contained in:
80
cuda_la.cc
80
cuda_la.cc
@@ -1,3 +1,6 @@
|
||||
/* vim: set ts=8 sw=8 sts=8 noexpandtab cindent: */
|
||||
/*******************************************************************************
|
||||
*******************************************************************************/
|
||||
#include "la_traits.h"
|
||||
#include "cuda_la.h"
|
||||
|
||||
@@ -7,63 +10,54 @@ namespace LA {
|
||||
|
||||
GPUID DEFAULT_LOC = cpu;
|
||||
|
||||
void set_default_loc(const GPUID loc)
|
||||
{
|
||||
DEFAULT_LOC = loc;
|
||||
void set_default_loc(const GPUID loc){
|
||||
DEFAULT_LOC = loc;
|
||||
}
|
||||
|
||||
void *gpualloc(size_t size)
|
||||
{
|
||||
cublasStatus status;
|
||||
void *ptr=NULL;
|
||||
status = cublasAlloc(size,1,&ptr);
|
||||
if(status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasAlloc");
|
||||
return ptr;
|
||||
void *gpualloc(size_t size){
|
||||
void *ptr = NULL;
|
||||
cublasAlloc(size, 1, &ptr);
|
||||
TEST_CUBLAS("cublasAlloc");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
void gpufree(void *ptr)
|
||||
{
|
||||
cublasStatus status = cublasFree(ptr);
|
||||
if (status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasFree");
|
||||
void gpufree(void *ptr){
|
||||
cublasFree(ptr);
|
||||
TEST_CUBLAS("cublasFree");
|
||||
}
|
||||
|
||||
void gpuget(size_t n, size_t elsize, const void *from, void *to)
|
||||
{
|
||||
cublasStatus status;
|
||||
status=cublasGetVector(n,elsize,from,1,to,1);
|
||||
if (status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasGetVector");
|
||||
void gpuget(size_t n, size_t elsize, const void *from, void *to){
|
||||
cublasGetVector(n, elsize, from, 1, to, 1);
|
||||
TEST_CUBLAS("cublasGetVector");
|
||||
}
|
||||
|
||||
void gpuput(size_t n, size_t elsize, const void *from, void *to)
|
||||
{
|
||||
cublasStatus status;
|
||||
status=cublasSetVector(n,elsize,from,1,to,1);
|
||||
if (status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasSetVector");
|
||||
void gpuput(size_t n, size_t elsize, const void *from, void *to){
|
||||
cublasSetVector(n, elsize, from, 1, to, 1);
|
||||
TEST_CUBLAS("cublasSetVector");
|
||||
}
|
||||
|
||||
double *gpuputdouble(const double &x)
|
||||
{
|
||||
cublasStatus status;
|
||||
void *ptr=NULL;
|
||||
status = cublasAlloc(1,sizeof(double),&ptr);
|
||||
if(status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasAlloc");
|
||||
status=cublasSetVector(1,sizeof(double),&x,1,ptr,1);
|
||||
if (status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasSetVector");
|
||||
return (double *)ptr;
|
||||
double *gpuputdouble(const double &x){
|
||||
void *ptr = NULL;
|
||||
cublasAlloc(1, sizeof(double), &ptr);
|
||||
TEST_CUBLAS("cublasAlloc");
|
||||
|
||||
cublasSetVector(1, sizeof(double), &x, 1, ptr, 1);
|
||||
TEST_CUBLAS("cublasSetVector");
|
||||
|
||||
return (double *)ptr;
|
||||
}
|
||||
|
||||
complex<double> *gpuputcomplex(const complex<double> &x)
|
||||
{
|
||||
cublasStatus status;
|
||||
void *ptr=NULL;
|
||||
status = cublasAlloc(1,sizeof(complex<double>),&ptr);
|
||||
if(status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasAlloc");
|
||||
status=cublasSetVector(1,sizeof(complex<double>),&x,1,ptr,1);
|
||||
if (status != CUBLAS_STATUS_SUCCESS) laerror("Error in cublasSetVector");
|
||||
return (complex<double> *)ptr;
|
||||
}
|
||||
complex<double> *gpuputcomplex(const complex<double> &x){
|
||||
void *ptr = NULL;
|
||||
cublasAlloc(1, sizeof(complex<double>), &ptr);
|
||||
TEST_CUBLAS("cublasAlloc");
|
||||
|
||||
cublasSetVector(1, sizeof(complex<double>), &x, 1, ptr, 1);
|
||||
TEST_CUBLAS("cublasSetVector");
|
||||
|
||||
return (complex<double> *)ptr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user