Skip to content

Commit

Permalink
WIP: ENH: Add naive CUDA schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
allemangD committed Sep 4, 2024
1 parent 5f77feb commit 5383a77
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/itkHalideDiscreteGaussianImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "itkHalideDiscreteGaussianImpl.h"

#include <Halide.h>
#include <HalideBuffer.h>

namespace itk
Expand Down Expand Up @@ -64,7 +65,9 @@ HalideDiscreteGaussianImageFilter<TInputImage, TOutputImage>::GenerateData()
Halide::Runtime::Buffer<const InputPixelType> inputBuffer(input->GetBufferPointer(), sizes);
Halide::Runtime::Buffer<OutputPixelType> outputBuffer(output->GetBufferPointer(), sizes);

inputBuffer.set_host_dirty();
itkHalideDiscreteGaussianImpl(inputBuffer, sigma_x, sigma_y, sigma_z, outputBuffer);
outputBuffer.copy_to_host();
}

} // end namespace itk
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ target_link_libraries(itkHalideGenerators PRIVATE Halide::Generator)
add_halide_library(itkHalideDiscreteGaussianImpl
FROM itkHalideGenerators
HEADER itkHalideDiscreteGaussianImpl_h
# PARAMS input.type=float32 output.type=float32
# PARAMS input.type=float32 output.type=float32
FEATURES cuda # debug
)

set(HalideFilters_SRCS
Expand Down
5 changes: 4 additions & 1 deletion src/generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class DiscreteGaussianGenerator : public Generator<DiscreteGaussianGenerator>

output(x, y, z) = blur_z(x, y, z);

output.vectorize(x, 4);

Var ix, iy, iz, ox, oy, oz;

output.gpu_tile(x, y, z, ix, iy, iz, ox, oy, oz, 4, 4, 4);
}
};

Expand Down
3 changes: 2 additions & 1 deletion test/itkHalideDiscreteGaussianImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ itkHalideDiscreteGaussianImageFilterTest(int argc, char * argv[])
}
const char * outputImageFileName = argv[1];

constexpr unsigned int Dimension = 2;
constexpr unsigned int Dimension = 3;
using PixelType = float;
using ImageType = itk::Image<PixelType, Dimension>;

Expand All @@ -85,6 +85,7 @@ itkHalideDiscreteGaussianImageFilterTest(int argc, char * argv[])
ShowProgress::Pointer showProgress = ShowProgress::New();
filter->AddObserver(itk::ProgressEvent(), showProgress);
filter->SetInput(image);
filter->SetSigma(2);

using WriterType = itk::ImageFileWriter<ImageType>;
WriterType::Pointer writer = WriterType::New();
Expand Down

0 comments on commit 5383a77

Please sign in to comment.