ImageSpotFinderGPU: Rename
This commit is contained in:
@@ -256,7 +256,7 @@ __global__ void analyze_pixel(const int32_t *in, uint32_t *out, const spot_param
|
||||
} while (back < rmax);
|
||||
}
|
||||
|
||||
GPUImageAnalysis::GPUImageAnalysis(int32_t in_xpixels, int32_t in_ypixels) :
|
||||
ImageSpotFinderGPU::ImageSpotFinderGPU(int32_t in_xpixels, int32_t in_ypixels) :
|
||||
xpixels(in_xpixels), ypixels(in_ypixels), gpu_out(nullptr) {
|
||||
|
||||
int device_count;
|
||||
@@ -281,7 +281,7 @@ GPUImageAnalysis::GPUImageAnalysis(int32_t in_xpixels, int32_t in_ypixels) :
|
||||
cuda_err(cudaHostAlloc(&host_out, output_byte_size(host_out, xpixels, ypixels), cudaHostAllocPortable));
|
||||
}
|
||||
|
||||
GPUImageAnalysis::~GPUImageAnalysis() {
|
||||
ImageSpotFinderGPU::~ImageSpotFinderGPU() {
|
||||
cudaStreamDestroy(cudastream->v);
|
||||
delete(cudastream);
|
||||
|
||||
@@ -290,18 +290,18 @@ GPUImageAnalysis::~GPUImageAnalysis() {
|
||||
cudaFree(gpu_out);
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::SetInputBuffer(void *ptr) {
|
||||
void ImageSpotFinderGPU::SetInputBuffer(void *ptr) {
|
||||
host_in = (int32_t *) ptr;
|
||||
}
|
||||
|
||||
bool GPUImageAnalysis::GPUPresent() {
|
||||
bool ImageSpotFinderGPU::GPUPresent() {
|
||||
int device_count;
|
||||
cuda_err(cudaGetDeviceCount(&device_count));
|
||||
|
||||
return (device_count > 0);
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::RunSpotFinder(const SpotFindingSettings &settings) {
|
||||
void ImageSpotFinderGPU::RunSpotFinder(const SpotFindingSettings &settings) {
|
||||
// data_in is CUDA registered memory
|
||||
|
||||
// Run COLSPOT (GPU version)
|
||||
@@ -345,7 +345,7 @@ void GPUImageAnalysis::RunSpotFinder(const SpotFindingSettings &settings) {
|
||||
cudaMemcpyDeviceToHost,cudastream->v));
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::GetSpotFinderResults(StrongPixelSet &pixel_set) {
|
||||
void ImageSpotFinderGPU::GetSpotFinderResults(StrongPixelSet &pixel_set) {
|
||||
if (host_in == nullptr)
|
||||
throw JFJochException(JFJochExceptionCategory::SpotFinderError, "Host/GPU buffer not defined");
|
||||
|
||||
@@ -368,7 +368,7 @@ void GPUImageAnalysis::GetSpotFinderResults(StrongPixelSet &pixel_set) {
|
||||
}
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::GetSpotFinderResults(const DiffractionExperiment &experiment,
|
||||
void ImageSpotFinderGPU::GetSpotFinderResults(const DiffractionExperiment &experiment,
|
||||
const SpotFindingSettings &settings,
|
||||
std::vector<DiffractionSpot> &vec) {
|
||||
StrongPixelSet pixel_set;
|
||||
@@ -376,15 +376,15 @@ void GPUImageAnalysis::GetSpotFinderResults(const DiffractionExperiment &experim
|
||||
pixel_set.FindSpotsImage(settings, vec);
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::RegisterBuffer() {
|
||||
void ImageSpotFinderGPU::RegisterBuffer() {
|
||||
cudaHostRegister(host_in, xpixels * ypixels * sizeof(int32_t), cudaHostRegisterDefault);
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::UnregisterBuffer() {
|
||||
void ImageSpotFinderGPU::UnregisterBuffer() {
|
||||
cudaHostUnregister(host_in);
|
||||
}
|
||||
|
||||
void GPUImageAnalysis::LoadDataToGPU() {
|
||||
void ImageSpotFinderGPU::LoadDataToGPU() {
|
||||
if (host_in == nullptr)
|
||||
throw JFJochException(JFJochExceptionCategory::SpotFinderError, "Host/GPU buffer not defined");
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
struct CudaStreamWrapper;
|
||||
|
||||
class GPUImageAnalysis {
|
||||
class ImageSpotFinderGPU {
|
||||
std::mutex m;
|
||||
CudaStreamWrapper *cudastream;
|
||||
|
||||
@@ -32,8 +32,8 @@ class GPUImageAnalysis {
|
||||
constexpr static int NBX = 15;
|
||||
public:
|
||||
|
||||
GPUImageAnalysis(int32_t xpixels, int32_t ypixels);
|
||||
~GPUImageAnalysis();
|
||||
ImageSpotFinderGPU(int32_t xpixels, int32_t ypixels);
|
||||
~ImageSpotFinderGPU();
|
||||
|
||||
void SetInputBuffer(void *host_in);
|
||||
void LoadDataToGPU();
|
||||
|
||||
@@ -21,13 +21,13 @@ static std::vector<DiffractionSpot> run_gpu_and_collect_spots(const std::vector<
|
||||
size_t width, size_t height,
|
||||
const SpotFindingSettings& settings)
|
||||
{
|
||||
GPUImageAnalysis gpu(static_cast<int32_t>(width), static_cast<int32_t>(height));
|
||||
REQUIRE(GPUImageAnalysis::GPUPresent());
|
||||
ImageSpotFinderGPU gpu(static_cast<int32_t>(width), static_cast<int32_t>(height));
|
||||
REQUIRE(ImageSpotFinderGPU::GPUPresent());
|
||||
|
||||
// Set input buffer pointer to our CPU data, register and upload
|
||||
// Note: RegisterBuffer/UnregisterBuffer are optional for plain memcpy path,
|
||||
// but we use them to mirror intended flow.
|
||||
const_cast<GPUImageAnalysis&>(gpu).SetInputBuffer((void*)input.data());
|
||||
const_cast<ImageSpotFinderGPU&>(gpu).SetInputBuffer((void*)input.data());
|
||||
gpu.RegisterBuffer();
|
||||
gpu.LoadDataToGPU();
|
||||
|
||||
@@ -47,7 +47,7 @@ static std::vector<DiffractionSpot> run_gpu_and_collect_spots(const std::vector<
|
||||
|
||||
// Mirror of ImageSpotFinder_SignalToNoise
|
||||
TEST_CASE("GPUImageAnalysis_SignalToNoise") {
|
||||
if (!GPUImageAnalysis::GPUPresent()) {
|
||||
if (!ImageSpotFinderGPU::GPUPresent()) {
|
||||
WARN("No CUDA GPU present. Skipping GPUImageAnalysis_SignalToNoise");
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ TEST_CASE("GPUImageAnalysis_SignalToNoise") {
|
||||
}
|
||||
|
||||
TEST_CASE("GPUImageAnalysis_CountThreshold") {
|
||||
if (!GPUImageAnalysis::GPUPresent()) {
|
||||
if (!ImageSpotFinderGPU::GPUPresent()) {
|
||||
WARN("No CUDA GPU present. Skipping GPUImageAnalysis_SignalToNoise");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user