Add cuda compile define and cmake setting
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#ifdef USE_CUDA
|
||||
#include "CudaMatrix.h"
|
||||
|
||||
#include "Function.h"
|
||||
@@ -218,6 +219,7 @@ CudaMatrix CudaMatrix::block(int aDim,int aBeginIndex, int aEndIndex) const
|
||||
return CudaMatrix::fromRawData(dataOutput,getDimSize(0),dimLength,getDimSize(2),getValueType());
|
||||
}
|
||||
case 2:
|
||||
default:
|
||||
{
|
||||
int copySize = dimLength*sliceStride;
|
||||
cudaMemcpy(dataOutput,
|
||||
@@ -235,4 +237,6 @@ bool CudaMatrix::setBlockValue(int aDim,int aBeginIndx, int aEndIndex,float valu
|
||||
std::cerr<<"CudaMatrix block only support 1D-3D data!"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // USE_CUDA
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef CUDAMATRIX_H
|
||||
#define CUDAMATRIX_H
|
||||
|
||||
#ifdef USE_CUDA
|
||||
#include "Matrix.h"
|
||||
|
||||
|
||||
@@ -235,5 +235,5 @@ namespace Aurora
|
||||
std::vector<int> mInfo;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // USE_CUDA
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Eigen>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
#ifdef USE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#endif
|
||||
|
||||
namespace Aurora {
|
||||
|
||||
@@ -26,9 +29,10 @@ namespace Aurora {
|
||||
void free(void* ptr){
|
||||
mkl_free(ptr);
|
||||
}
|
||||
|
||||
#ifdef USE_CUDA
|
||||
void gpuFree(void* ptr)
|
||||
{
|
||||
cudaFree(ptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "Eigen/src/Core/Matrix.h"
|
||||
#include "Function.h"
|
||||
|
||||
#ifdef USE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#endif
|
||||
|
||||
namespace Aurora{
|
||||
typedef void(*CalcFuncD)(const MKL_INT n, const float a[], const MKL_INT inca, const float b[],
|
||||
@@ -394,6 +396,7 @@ namespace Aurora {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef USE_CUDA
|
||||
CudaMatrix Matrix::toDeviceMatrix() const
|
||||
{
|
||||
float* deviceData = nullptr;
|
||||
@@ -401,7 +404,7 @@ namespace Aurora {
|
||||
cudaMemcpy(deviceData, mData.get(), sizeof(float) * getDataSize() * getValueType(), cudaMemcpyHostToDevice);
|
||||
return CudaMatrix::fromRawData(deviceData, mInfo[0], mInfo[1], mInfo[2], getValueType());
|
||||
}
|
||||
|
||||
#endif
|
||||
Matrix Matrix::New(float *data, const Matrix &shapeMatrix) {
|
||||
return New(data,
|
||||
shapeMatrix.getDimSize(0),
|
||||
|
||||
Reference in New Issue
Block a user