RadialIntegration: Calculate only on FPGA
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "../image_analysis/IndexerWrapper.h"
|
||||
|
||||
#include "../image_analysis/RadialIntegration.h"
|
||||
#include "../common/Logger.h"
|
||||
#include "../image_analysis/PredictSpotsOnDetector.h"
|
||||
|
||||
@@ -32,12 +31,10 @@ auto TestAll(const DiffractionExperiment &experiment, const JFJochProtoBuf::Data
|
||||
spot_finder.LoadDataToGPU();
|
||||
spot_finder.RunSpotFinder(settings);
|
||||
spot_finder.GetSpotFinderResults(experiment, settings, spots);
|
||||
spot_finder.RunRadialIntegration();
|
||||
std::vector<Coord> recip;
|
||||
for (const auto& s: spots)
|
||||
recip.emplace_back(s.ReciprocalCoord(experiment));
|
||||
indexer.Run(recip);
|
||||
spot_finder.GetRadialIntegrationProfile(result);
|
||||
}
|
||||
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
@@ -68,12 +65,10 @@ auto TestAllWithROI(const DiffractionExperiment &experiment, const JFJochProtoBu
|
||||
spot_finder.LoadDataToGPU();
|
||||
spot_finder.RunSpotFinder(settings);
|
||||
spot_finder.GetSpotFinderResults(experiment, settings, spots);
|
||||
spot_finder.RunRadialIntegration();
|
||||
std::vector<Coord> recip;
|
||||
for (const auto& s: spots)
|
||||
recip.emplace_back(s.ReciprocalCoord(experiment));
|
||||
auto indexer_ret = indexer.Run(recip);
|
||||
spot_finder.GetRadialIntegrationProfile(result);
|
||||
if (!indexer_ret.empty()) {
|
||||
PredictSpotsOnDetector(filter, experiment, indexer_ret[0].l);
|
||||
filter.Apply<int16_t>(roi_image, INT16_MIN);
|
||||
@@ -178,89 +173,6 @@ auto TestSpotFinderWithoutCopyToDevice(const DiffractionExperiment &experiment,
|
||||
return strstream.str();
|
||||
}
|
||||
|
||||
auto TestRadialIntegrationGPU(const DiffractionExperiment &x,
|
||||
const JFJochProtoBuf::DataProcessingSettings &settings,
|
||||
int16_t* image, size_t nimages) {
|
||||
|
||||
uint32_t nredo = 20;
|
||||
RadialIntegrationMapping mapping(x);
|
||||
|
||||
std::vector<uint8_t> one_byte_mask(x.GetPixelsNum(), 1);
|
||||
GPUImageAnalysis integration(x.GetXPixelsNum(), x.GetYPixelsNum(), one_byte_mask, mapping);
|
||||
|
||||
integration.SetInputBuffer(image);
|
||||
|
||||
std::vector<float> result;
|
||||
|
||||
auto start_time = std::chrono::system_clock::now();
|
||||
for (int redo = 0; redo < nredo; redo++) {
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
integration.LoadDataToGPU();
|
||||
integration.RunRadialIntegration();
|
||||
integration.GetRadialIntegrationProfile(result);
|
||||
}
|
||||
}
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
||||
|
||||
return elapsed.count() / (1000.0 * (double) nimages * nredo);
|
||||
}
|
||||
|
||||
auto TestRadialIntegrationGPUWithoutCopyToDevice(const DiffractionExperiment &x,
|
||||
const JFJochProtoBuf::DataProcessingSettings &settings,
|
||||
int16_t* image, size_t nimages) {
|
||||
|
||||
uint32_t nredo = 20;
|
||||
RadialIntegrationMapping mapping(x);
|
||||
|
||||
std::vector<uint8_t> one_byte_mask(x.GetPixelsNum(), 1);
|
||||
GPUImageAnalysis integration(x.GetXPixelsNum(), x.GetYPixelsNum(), one_byte_mask, mapping);
|
||||
|
||||
integration.SetInputBuffer(image);
|
||||
|
||||
std::vector<float> result;
|
||||
|
||||
integration.LoadDataToGPU();
|
||||
|
||||
auto start_time = std::chrono::system_clock::now();
|
||||
for (int redo = 0; redo < nredo; redo++) {
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
integration.RunRadialIntegration();
|
||||
integration.GetRadialIntegrationProfile(result);
|
||||
}
|
||||
}
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
||||
|
||||
return elapsed.count() / (1000.0 * (double) nimages * nredo);
|
||||
}
|
||||
|
||||
|
||||
auto TestRadialIntegration(const DiffractionExperiment &experiment,
|
||||
const JFJochProtoBuf::DataProcessingSettings &settings,
|
||||
int16_t* image, size_t nimages) {
|
||||
|
||||
uint32_t nredo = 20;
|
||||
RadialIntegrationMapping mapping(experiment);
|
||||
std::unique_ptr<RadialIntegration> integration;
|
||||
|
||||
integration = std::make_unique<RadialIntegration>(mapping);
|
||||
|
||||
std::vector<float> result;
|
||||
|
||||
auto start_time = std::chrono::system_clock::now();
|
||||
for (int redo = 0; redo < nredo; redo++) {
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
integration->ProcessOneImage(image + i * experiment.GetPixelsNum(), experiment.GetPixelsNum());
|
||||
//integration.GetResult(result);
|
||||
}
|
||||
}
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
||||
|
||||
return elapsed.count() / (1000.0 * (double) nimages * nredo);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterHDF5Filter();
|
||||
|
||||
@@ -315,7 +227,6 @@ int main(int argc, char **argv) {
|
||||
settings.set_local_bkg_size(5);
|
||||
|
||||
std::vector<uint8_t> one_byte_mask(x.GetPixelsNum(), 1);
|
||||
RadialIntegrationMapping mapping(x);
|
||||
|
||||
logger.Info("COLSPOT NBX=NBY=5 (GPU)");
|
||||
if (GPUImageAnalysis::GPUPresent()) {
|
||||
@@ -335,19 +246,11 @@ int main(int argc, char **argv) {
|
||||
TestSpotFinder(x, settings, local_peakfinder_gpu,image_conv.data(), nimages);
|
||||
}
|
||||
|
||||
logger.Info("{:30s} {:8.1f} ms/image", "Radial int. (GPU)", TestRadialIntegrationGPU(x, settings,
|
||||
image_conv.data(), nimages));
|
||||
logger.Info("{:30s} {:8.1f} ms/image", "Radial int. (GPU/nocpy)", TestRadialIntegrationGPUWithoutCopyToDevice(x, settings,
|
||||
image_conv.data(), nimages));
|
||||
|
||||
logger.Info("{:30s} {:8.1f} ms/image", "Radial int. (CPU)", TestRadialIntegration(x, settings,
|
||||
image_conv.data(), nimages));
|
||||
|
||||
TestIndexing();
|
||||
|
||||
logger.Info("Full package");
|
||||
if (GPUImageAnalysis::GPUPresent()) {
|
||||
GPUImageAnalysis local_peakfinder_gpu(x.GetXPixelsNum(), x.GetYPixelsNum(), one_byte_mask, mapping);
|
||||
GPUImageAnalysis local_peakfinder_gpu(x.GetXPixelsNum(), x.GetYPixelsNum(), one_byte_mask);
|
||||
TestAll(x, settings, local_peakfinder_gpu,image_conv.data(), nimages);
|
||||
TestAllWithROI(x, settings, local_peakfinder_gpu,image_conv.data(), nimages);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user