Skip to content

Commit

Permalink
BUG: Fix dereferencing of GPU buffer pointer after CudaCommon API change
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGandel authored and SimonRit committed Dec 6, 2024
1 parent 1de9d77 commit 8f9d009
Show file tree
Hide file tree
Showing 28 changed files with 209 additions and 9 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ if(NOT ITK_SOURCE_DIR)
endif()
endif()

# Propagate cmake options in a header file
configure_file(${RTK_SOURCE_DIR}/rtkConfiguration.h.in
${RTK_BINARY_DIR}/rtkConfiguration.h)

#=========================================================
# If choose to build documentation, then search for Doxygen/Sphinx executables.
option(RTK_BUILD_DOXYGEN "Build Doxygen Documentation" OFF)
Expand Down Expand Up @@ -237,6 +233,11 @@ else()
itk_module_impl()
endif()

# Propagate cmake options in a header file
# Must be done after the external module configuration to make sure CudaCommon_SOURCE_DIR is defined
configure_file(${RTK_SOURCE_DIR}/rtkConfiguration.h.in
${RTK_BINARY_DIR}/rtkConfiguration.h)

# Install lpsolve headers
install(FILES ${RTK_SOURCE_DIR}/utilities/lp_solve/lp_bit.h
${RTK_SOURCE_DIR}/utilities/lp_solve/lp_crash.h
Expand Down
8 changes: 7 additions & 1 deletion include/rtkCudaBackProjectionImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ CudaBackProjectionImageFilter<ImageType>::GPUGenerateData()
volumeSize[1] = this->GetOutput()->GetBufferedRegion().GetSize()[1];
volumeSize[2] = this->GetOutput()->GetBufferedRegion().GetSize()[2];

# ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * stackGPUPointer = (float *)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
# else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * stackGPUPointer = *(float **)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
# endif

float * stackGPUPointer = *(float **)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
ptrdiff_t projSize = this->GetInput(1)->GetBufferedRegion().GetSize()[0] *
this->GetInput(1)->GetBufferedRegion().GetSize()[1] *
itk::NumericTraits<typename ImageType::PixelType>::GetLength();
Expand Down
22 changes: 22 additions & 0 deletions include/rtkCudaConjugateGradientImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ CudaConjugateGradientImageFilter<TImage>::GPUGenerateData()
R_k->CopyInformation(this->GetOutput());

// Copy the input to the output (X_0 = input)
# ifdef CUDACOMMON_VERSION_MAJOR
DataType * pin = (DataType *)(this->GetX()->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pX = (DataType *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
# else
DataType * pin = *(DataType **)(this->GetX()->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pX = *(DataType **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// On GPU, initialize the output to the input
CUDA_copy(numberOfElements, pin, pX);
Expand All @@ -70,9 +75,15 @@ CudaConjugateGradientImageFilter<TImage>::GPUGenerateData()
typename TImage::Pointer AOut = this->m_A->GetOutput();
AOut->DisconnectPipeline();

# ifdef CUDACOMMON_VERSION_MAJOR
DataType * pR = (DataType *)(R_k->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pB = (DataType *)(this->GetB()->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pAOut = (DataType *)(AOut->GetCudaDataManager()->GetGPUBufferPointer());
# else
DataType * pR = *(DataType **)(R_k->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pB = *(DataType **)(this->GetB()->GetCudaDataManager()->GetGPUBufferPointer());
DataType * pAOut = *(DataType **)(AOut->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// Compute, on GPU, R_zero = P_zero = this->GetB() - this->m_A->GetOutput()
CUDA_copy(numberOfElements, pB, pR);
Expand All @@ -82,7 +93,11 @@ CudaConjugateGradientImageFilter<TImage>::GPUGenerateData()
// Transfer it back to the CPU memory
this->GetB()->GetCudaDataManager()->GetCPUBufferPointer();

# ifdef CUDACOMMON_VERSION_MAJOR
DataType * pP = (DataType *)(P_k->GetCudaDataManager()->GetGPUBufferPointer());
# else
DataType * pP = *(DataType **)(P_k->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// P0 = R0
CUDA_copy(numberOfElements, pR, pP);
Expand All @@ -97,10 +112,17 @@ CudaConjugateGradientImageFilter<TImage>::GPUGenerateData()
AOut = this->m_A->GetOutput();
AOut->DisconnectPipeline();

# ifdef CUDACOMMON_VERSION_MAJOR
pX = (DataType *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
pR = (DataType *)(R_k->GetCudaDataManager()->GetGPUBufferPointer());
pP = (DataType *)(P_k->GetCudaDataManager()->GetGPUBufferPointer());
pAOut = (DataType *)(AOut->GetCudaDataManager()->GetGPUBufferPointer());
# else
pX = *(DataType **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
pR = *(DataType **)(R_k->GetCudaDataManager()->GetGPUBufferPointer());
pP = *(DataType **)(P_k->GetCudaDataManager()->GetGPUBufferPointer());
pAOut = *(DataType **)(AOut->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// Compute, on GPU, alpha_k (only on GPU), X_k+1 (output), R_k+1, beta_k (only on GPU), P_k+1
// The inputs are replaced by their next iterate
Expand Down
10 changes: 10 additions & 0 deletions include/rtkCudaFFTProjectionsConvolutionImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ CudaFFTProjectionsConvolutionImageFilter<TParentImageFilter>::PadInputImageRegio
sz_i.y = inBuffRegion.GetSize()[1];
sz_i.z = inBuffRegion.GetSize()[2];

# ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(paddedImage->GetCudaDataManager()->GetGPUBufferPointer());
# else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(paddedImage->GetCudaDataManager()->GetGPUBufferPointer());
# endif

CUDA_padding(idx, sz, sz_i, pin, pout, TParentImageFilter::m_TruncationMirrorWeights);

Expand Down Expand Up @@ -132,8 +137,13 @@ CudaFFTProjectionsConvolutionImageFilter<TParentImageFilter>::GPUGenerateData()
kernelDimension.y = this->m_KernelFFT->GetBufferedRegion().GetSize()[1];
CUDA_fft_convolution(inputDimension,
kernelDimension,
# ifdef CUDACOMMON_VERSION_MAJOR
(float *)(cuPadImgP->GetCudaDataManager()->GetGPUBufferPointer()),
(float2 *)(this->m_KernelFFTCUDA->GetCudaDataManager()->GetGPUBufferPointer()));
# else
*(float **)(cuPadImgP->GetCudaDataManager()->GetGPUBufferPointer()),
*(float2 **)(this->m_KernelFFTCUDA->GetCudaDataManager()->GetGPUBufferPointer()));
# endif

/* Impossible to get a pixel-wise progress reporting with CUDA
* so this filter only reports 0 and 100% completion. */
Expand Down
6 changes: 6 additions & 0 deletions include/rtkCudaForwardProjectionImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ CudaForwardProjectionImageFilter<TInputImage, TOutputImage>::GPUGenerateData()
volumeSize[1] = this->GetInput(1)->GetBufferedRegion().GetSize()[1];
volumeSize[2] = this->GetInput(1)->GetBufferedRegion().GetSize()[2];

# ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput(0)->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pvol = (float *)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
# else
float * pin = *(float **)(this->GetInput(0)->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pvol = *(float **)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// Account for system rotations
typename Superclass::GeometryType::ThreeDHomogeneousMatrixType volPPToIndex;
Expand Down
11 changes: 10 additions & 1 deletion include/rtkCudaWeidingerForwardModelImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,22 @@ CudaWeidingerForwardModelImageFilter<TMaterialProjections, TPhotonCounts, TSpect
for (unsigned int d = 0; d < Dimension; d++)
projectionSize[d] = this->GetInputMaterialProjections()->GetBufferedRegion().GetSize()[d];

// Pointers to inputs and outputs
// Pointers to inputs and outputs
# ifdef CUDACOMMON_VERSION_MAJOR
float * pMatProj = (float *)(this->GetInputMaterialProjections()->GetCudaDataManager()->GetGPUBufferPointer());
float * pPhoCount = (float *)(this->GetInputPhotonCounts()->GetCudaDataManager()->GetGPUBufferPointer());
float * pSpectrum = (float *)(this->GetInputSpectrum()->GetCudaDataManager()->GetGPUBufferPointer());
float * pProjOnes = (float *)(this->GetInputProjectionsOfOnes()->GetCudaDataManager()->GetGPUBufferPointer());
float * pOut1 = (float *)(this->GetOutput1()->GetCudaDataManager()->GetGPUBufferPointer());
float * pOut2 = (float *)(this->GetOutput2()->GetCudaDataManager()->GetGPUBufferPointer());
# else
float * pMatProj = *(float **)(this->GetInputMaterialProjections()->GetCudaDataManager()->GetGPUBufferPointer());
float * pPhoCount = *(float **)(this->GetInputPhotonCounts()->GetCudaDataManager()->GetGPUBufferPointer());
float * pSpectrum = *(float **)(this->GetInputSpectrum()->GetCudaDataManager()->GetGPUBufferPointer());
float * pProjOnes = *(float **)(this->GetInputProjectionsOfOnes()->GetCudaDataManager()->GetGPUBufferPointer());
float * pOut1 = *(float **)(this->GetOutput1()->GetCudaDataManager()->GetGPUBufferPointer());
float * pOut2 = *(float **)(this->GetOutput2()->GetCudaDataManager()->GetGPUBufferPointer());
# endif

// Run the forward projection with a slab of SLAB_SIZE or less projections
CUDA_WeidingerForwardModel(
Expand Down
6 changes: 6 additions & 0 deletions rtkConfiguration.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ using ThreadIdType = itk::ThreadIdType;
# define SLAB_SIZE @RTK_CUDA_PROJECTIONS_SLAB_SIZE@
#endif

// CudaCommon_SOURCE_DIR and cudaCommonConfiguration.h were introduced in CudaCommon 2.0
#cmakedefine CudaCommon_SOURCE_DIR
#ifdef CudaCommon_SOURCE_DIR
# include <cudaCommonConfiguration.h>
#endif

#define RTK_BINARY_DIR "@RTK_BINARY_DIR@"
#define RTK_DATA_ROOT "@RTK_DATA_ROOT@"

Expand Down
6 changes: 6 additions & 0 deletions src/rtkCudaAverageOutOfROIImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ rtk::CudaAverageOutOfROIImageFilter ::GPUGenerateData()
size[i] = this->GetOutput()->GetBufferedRegion().GetSize()[i];
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * proi = (float *)(this->GetROI()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * proi = *(float **)(this->GetROI()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_average_out_of_ROI(size, pin, pout, proi);

Expand Down
4 changes: 4 additions & 0 deletions src/rtkCudaConstantVolumeSeriesSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ rtk::CudaConstantVolumeSeriesSource ::GPUGenerateData()
outputSize[i] = this->GetOutput()->GetRequestedRegion().GetSize()[i];
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_generate_constant_volume_series(outputSize, pout, m_Constant);
}
4 changes: 4 additions & 0 deletions src/rtkCudaConstantVolumeSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ rtk::CudaConstantVolumeSource ::GPUGenerateData()
outputSize[i] = this->GetOutput()->GetRequestedRegion().GetSize()[i];
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_generate_constant_volume(outputSize, pout, m_Constant);
}
5 changes: 5 additions & 0 deletions src/rtkCudaCropImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ CudaCropImageFilter ::GPUGenerateData()
itkExceptionMacro(<< "CudaCropImageFilter assumes that requested and buffered regions are equal.");
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_crop(idx, sz, input_sz, pin, pout);
}
Expand Down
5 changes: 5 additions & 0 deletions src/rtkCudaCyclicDeformationImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ rtk::CudaCyclicDeformationImageFilter ::GPUGenerateData()
}
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_linear_interpolate_along_fourth_dimension(
inputSize, pin, pout, this->m_FrameInf, this->m_FrameSup, this->m_WeightInf, this->m_WeightSup);
Expand Down
8 changes: 8 additions & 0 deletions src/rtkCudaDisplacedDetectorImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ CudaDisplacedDetectorImageFilter ::GPUGenerateData()
overlapRegion.Crop(this->GetInput()->GetBufferedRegion());

// Put the two data pointers at the same location
#ifdef CUDACOMMON_VERSION_MAJOR
float * inBuffer = static_cast<float *>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * inBuffer = *static_cast<float **>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
inBuffer += this->GetInput()->ComputeOffset(overlapRegion.GetIndex());
#ifdef CUDACOMMON_VERSION_MAJOR
float * outBuffer = static_cast<float *>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * outBuffer = *static_cast<float **>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
outBuffer += this->GetOutput()->ComputeOffset(this->GetOutput()->GetRequestedRegion().GetIndex());

// nothing to do
Expand Down
8 changes: 7 additions & 1 deletion src/rtkCudaFDKBackProjectionImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ CudaFDKBackProjectionImageFilter ::GPUGenerateData()
volumeSize[1] = this->GetOutput()->GetBufferedRegion().GetSize()[1];
volumeSize[2] = this->GetOutput()->GetBufferedRegion().GetSize()[2];

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * stackGPUPointer = (float *)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * stackGPUPointer = *(float **)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
#endif

float * stackGPUPointer = *(float **)(this->GetInput(1)->GetCudaDataManager()->GetGPUBufferPointer());
ptrdiff_t projSize =
this->GetInput(1)->GetBufferedRegion().GetSize()[0] * this->GetInput(1)->GetBufferedRegion().GetSize()[1];
stackGPUPointer += projSize * (iFirstProj - this->GetInput(1)->GetBufferedRegion().GetIndex()[2]);
Expand Down
8 changes: 8 additions & 0 deletions src/rtkCudaFDKWeightProjectionFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,17 @@ CudaFDKWeightProjectionFilter ::GPUGenerateData()
}

// Put the two data pointers at the same location
#ifdef CUDACOMMON_VERSION_MAJOR
float * inBuffer = static_cast<float *>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * inBuffer = *static_cast<float **>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
inBuffer += this->GetInput()->ComputeOffset(this->GetInput()->GetRequestedRegion().GetIndex());
#ifdef CUDACOMMON_VERSION_MAJOR
float * outBuffer = static_cast<float *>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * outBuffer = *static_cast<float **>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
outBuffer += this->GetOutput()->ComputeOffset(this->GetOutput()->GetRequestedRegion().GetIndex());

CUDA_weight_projection(proj_idx,
Expand Down
8 changes: 8 additions & 0 deletions src/rtkCudaForwardWarpImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,19 @@ CudaForwardWarpImageFilter ::GPUGenerateData()
++itDVF;
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pinVol = (float *)(this->GetInput(0)->GetCudaDataManager()->GetGPUBufferPointer());
float * poutVol = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pinxDVF = (float *)(xCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
float * pinyDVF = (float *)(yCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
float * pinzDVF = (float *)(zCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pinVol = *(float **)(this->GetInput(0)->GetCudaDataManager()->GetGPUBufferPointer());
float * poutVol = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pinxDVF = *(float **)(xCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
float * pinyDVF = *(float **)(yCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
float * pinzDVF = *(float **)(zCompDVF->GetCudaDataManager()->GetGPUBufferPointer());
#endif

// Transform matrices that we will need during the ForwardWarping process
indexInputToPPInputMatrix =
Expand Down
5 changes: 5 additions & 0 deletions src/rtkCudaInterpolateImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ rtk::CudaInterpolateImageFilter ::GPUGenerateData()
inputSize.z = this->GetInputVolumeSeries()->GetBufferedRegion().GetSize()[2];
inputSize.w = this->GetInputVolumeSeries()->GetBufferedRegion().GetSize()[3];

#ifdef CUDACOMMON_VERSION_MAJOR
float * pvolseries = (float *)(this->GetInputVolumeSeries()->GetCudaDataManager()->GetGPUBufferPointer());
float * pvol = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pvolseries = *(float **)(this->GetInputVolumeSeries()->GetCudaDataManager()->GetGPUBufferPointer());
float * pvol = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_interpolation(inputSize, pvolseries, pvol, m_ProjectionNumber, m_Weights.data_array());
}
10 changes: 10 additions & 0 deletions src/rtkCudaLagCorrectionImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ CudaLagCorrectionImageFilter ::GPUGenerateData()
// overlapRegion.Crop(this->GetInput()->GetBufferedRegion());

// Put the two data pointers at the same location
#ifdef CUDACOMMON_VERSION_MAJOR
unsigned short * inBuffer =
static_cast<unsigned short *>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
unsigned short * inBuffer =
*static_cast<unsigned short **>(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
inBuffer += this->GetInput()->ComputeOffset(overlapRegion.GetIndex());
#ifdef CUDACOMMON_VERSION_MAJOR
unsigned short * outBuffer =
static_cast<unsigned short *>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
unsigned short * outBuffer =
*static_cast<unsigned short **>(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif
outBuffer += this->GetOutput()->ComputeOffset(this->GetOutput()->GetRequestedRegion().GetIndex());

int proj_idx_in[3];
Expand Down
5 changes: 5 additions & 0 deletions src/rtkCudaLaplacianImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ rtk::CudaLaplacianImageFilter ::GPUGenerateData()
}
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_laplacian(inputSize, inputSpacing, pin, pout);
}
5 changes: 5 additions & 0 deletions src/rtkCudaLastDimensionTVDenoisingImageFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ rtk::CudaLastDimensionTVDenoisingImageFilter ::GPUGenerateData()
}
}

#ifdef CUDACOMMON_VERSION_MAJOR
float * pin = (float *)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = (float *)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#else
float * pin = *(float **)(this->GetInput()->GetCudaDataManager()->GetGPUBufferPointer());
float * pout = *(float **)(this->GetOutput()->GetCudaDataManager()->GetGPUBufferPointer());
#endif

CUDA_total_variation_last_dimension(
inputSize, pin, pout, static_cast<float>(m_Gamma), static_cast<float>(m_Beta), m_NumberOfIterations);
Expand Down
Loading

0 comments on commit 8f9d009

Please sign in to comment.