54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
// Copyright (2019-2024) Paul Scherrer Institute
|
|
|
|
#include <iostream>
|
|
#include <chrono>
|
|
#include <future>
|
|
|
|
#include "../image_analysis/AzimuthalIntegrationMapping.h"
|
|
#include "../image_analysis/AzimuthalIntegration.h"
|
|
|
|
#include "../common/RawToConvertedGeometry.h"
|
|
#include "../common/Logger.h"
|
|
|
|
int main() {
|
|
Logger logger("azimuthal_gpu_test");
|
|
|
|
DiffractionExperiment experiment(DetectorGeometry(18, 3, 8, 36));
|
|
experiment.BeamX_pxl(1090).BeamY_pxl(1136).DetectorDistance_mm(75).PhotonEnergy_keV(WVL_1A_IN_KEV);
|
|
experiment.QSpacingForAzimInt_recipA(0.02);
|
|
AzimuthalIntegrationMapping map(experiment);
|
|
|
|
std::cout << map.GetBinNumber() << std::endl;
|
|
auto map_raw = map.GetPixelToBinMappingRaw();
|
|
std::vector<uint16_t> map_conv(experiment.GetPixelsNum());
|
|
RawToConvertedGeometry(experiment, map_conv.data(), map_raw.data());
|
|
|
|
std::vector<double> sum(map.GetBinNumber());
|
|
std::vector<double> sum2(map.GetBinNumber());
|
|
std::vector<uint32_t> count(map.GetBinNumber());
|
|
|
|
std::vector<int16_t> image(experiment.GetPixelsNum(), 5);
|
|
|
|
std::vector<float> coeff(experiment.GetPixelsNum(), 1.0);
|
|
|
|
auto const iterations = 1000;
|
|
auto const threads = 16;
|
|
std::vector<std::future<void>> futures;
|
|
|
|
auto start_time = std::chrono::system_clock::now();
|
|
|
|
for (int j = 0; j < threads; j++) {
|
|
futures.emplace_back(std::async(std::launch::async, [&] {
|
|
AzimuthalIntegration azim(experiment, map);
|
|
for (int i = 0; i < iterations; i++)
|
|
azim.Process(image.data(), experiment.GetPixelsNum());
|
|
}));
|
|
}
|
|
|
|
for (auto &f: futures)
|
|
f.get();
|
|
|
|
auto end_time = std::chrono::system_clock::now();
|
|
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
|
logger.Info("Performance {:.2f} us", elapsed.count() / static_cast<double>(iterations * threads));
|
|
} |