check if algorithm could be run on cuda
This commit is contained in:
@@ -79,6 +79,17 @@ public:
|
||||
*/
|
||||
void Run();
|
||||
|
||||
/**
|
||||
* @brief Returns VRAM if image or kernel data is on GPU, RAM otherwise.
|
||||
*/
|
||||
MemoryDevice GetPreferredDevice() const override {
|
||||
if (m_Image && m_Image->Data().GetDevice() == MemoryDevice::VRAM)
|
||||
return MemoryDevice::VRAM;
|
||||
if (m_KernelData.ConstData().GetDevice() == MemoryDevice::VRAM)
|
||||
return MemoryDevice::VRAM;
|
||||
return MemoryDevice::RAM;
|
||||
}
|
||||
|
||||
void SetKernelNumericXZY(const std::vector<float> &numeric);
|
||||
|
||||
void SetKernelSpherical(float (*shape)(float));
|
||||
|
||||
@@ -109,7 +109,8 @@ public:
|
||||
}
|
||||
|
||||
#if defined(USE_CUDA) && defined(__CUDACC__)
|
||||
void Run() {
|
||||
VoxImage<VoxelT>* Process(VoxImage<VoxelT>* const& image) override {
|
||||
if (this->m_Image != image) this->SetImage(image);
|
||||
if (this->m_Image->Data().GetDevice() == MemoryDevice::VRAM ||
|
||||
this->m_KernelData.Data().GetDevice() == MemoryDevice::VRAM) {
|
||||
|
||||
@@ -136,8 +137,9 @@ public:
|
||||
d_img_in, d_img_out, d_kernel, vox_size, ker_size, center_count,
|
||||
mAtrim, mBtrim);
|
||||
cudaDeviceSynchronize();
|
||||
return this->m_Image;
|
||||
} else {
|
||||
BaseClass::Run();
|
||||
return BaseClass::Process(image);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -207,7 +209,8 @@ public:
|
||||
}
|
||||
|
||||
#if defined(USE_CUDA) && defined(__CUDACC__)
|
||||
void Run() {
|
||||
VoxImage<VoxelT>* Process(VoxImage<VoxelT>* const& image) override {
|
||||
if (this->m_Image != image) this->SetImage(image);
|
||||
if (this->m_Image->Data().GetDevice() == MemoryDevice::VRAM ||
|
||||
this->m_KernelData.Data().GetDevice() == MemoryDevice::VRAM) {
|
||||
|
||||
@@ -234,8 +237,9 @@ public:
|
||||
d_img_in, d_img_out, d_kernel, vox_size, ker_size, center_count,
|
||||
mAtrim, mBtrim);
|
||||
cudaDeviceSynchronize();
|
||||
return this->m_Image;
|
||||
} else {
|
||||
BaseClass::Run();
|
||||
return BaseClass::Process(image);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -67,7 +67,8 @@ public:
|
||||
VoxFilterAlgorithmLinear(const Vector3i &size) : BaseClass(size) {}
|
||||
|
||||
#if defined(USE_CUDA) && defined(__CUDACC__)
|
||||
void Run() {
|
||||
VoxImage<VoxelT>* Process(VoxImage<VoxelT>* const& image) override {
|
||||
if (this->m_Image != image) this->SetImage(image);
|
||||
if (this->m_Image->Data().GetDevice() == MemoryDevice::VRAM ||
|
||||
this->m_KernelData.Data().GetDevice() == MemoryDevice::VRAM) {
|
||||
|
||||
@@ -92,8 +93,9 @@ public:
|
||||
LinearFilterKernel<<<blocksPerGrid, threadsPerBlock>>>(
|
||||
d_img_in, d_img_out, d_kernel, vox_size, ker_size, center_count);
|
||||
cudaDeviceSynchronize();
|
||||
return this->m_Image;
|
||||
} else {
|
||||
BaseClass::Run();
|
||||
return BaseClass::Process(image);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user