// Copyright (2019-2024) Paul Scherrer Institute #include #include #include #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 map_conv(experiment.GetPixelsNum()); RawToConvertedGeometry(experiment, map_conv.data(), map_raw.data()); std::vector sum(map.GetBinNumber()); std::vector sum2(map.GetBinNumber()); std::vector count(map.GetBinNumber()); std::vector image(experiment.GetPixelsNum(), 5); std::vector coeff(experiment.GetPixelsNum(), 1.0); auto const iterations = 1000; auto const threads = 16; std::vector> 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(end_time - start_time); logger.Info("Performance {:.2f} us", elapsed.count() / static_cast(iterations * threads)); }