Skip to content

Commit 83dbbb6

Browse files
authored
Merge pull request #380 from guilhermeAlmeida1/patch-1
Ensure synchronisation with async copies
2 parents baa7fce + b47d40e commit 83dbbb6

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

device/common/src/make_prefix_sum_buffer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ prefix_sum_buffer_t make_prefix_sum_buffer(
3434
vecmem::data::vector_buffer<prefix_sum_size_t> sizes_sum_buff(
3535
sizes_sum.size(), mr.main);
3636
copy.setup(sizes_sum_buff);
37-
(copy)(vecmem::get_data(sizes_sum), sizes_sum_buff);
37+
(copy)(vecmem::get_data(sizes_sum), sizes_sum_buff)->wait();
3838
vecmem::data::vector_view<prefix_sum_size_t> sizes_sum_view(
3939
sizes_sum_buff);
4040

examples/run/cuda/seeding_example_cuda.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <vecmem/memory/cuda/device_memory_resource.hpp>
2727
#include <vecmem/memory/host_memory_resource.hpp>
2828
#include <vecmem/utils/cuda/async_copy.hpp>
29-
#include <vecmem/utils/cuda/copy.hpp>
3029

3130
// ACTS include(s).
3231
#include <Acts/Definitions/Units.hpp>
@@ -60,11 +59,10 @@ int seq_run(const traccc::seeding_input_config& i_cfg,
6059

6160
traccc::cuda::stream stream;
6261

63-
vecmem::cuda::copy copy;
64-
vecmem::cuda::async_copy async_copy{stream.cudaStream()};
62+
vecmem::cuda::async_copy copy{stream.cudaStream()};
6563

66-
traccc::cuda::seeding_algorithm sa_cuda{mr, async_copy, stream};
67-
traccc::cuda::track_params_estimation tp_cuda{mr, async_copy, stream};
64+
traccc::cuda::seeding_algorithm sa_cuda{mr, copy, stream};
65+
traccc::cuda::track_params_estimation tp_cuda{mr, copy, stream};
6866

6967
// performance writer
7068
traccc::seeding_performance_writer sd_performance_writer(
@@ -169,8 +167,8 @@ int seq_run(const traccc::seeding_input_config& i_cfg,
169167
// Copy the seeds to the host for comparisons
170168
traccc::seed_collection_types::host seeds_cuda;
171169
traccc::bound_track_parameters_collection_types::host params_cuda;
172-
copy(seeds_cuda_buffer, seeds_cuda);
173-
copy(params_cuda_buffer, params_cuda);
170+
copy(seeds_cuda_buffer, seeds_cuda)->wait();
171+
copy(params_cuda_buffer, params_cuda)->wait();
174172

175173
if (run_cpu) {
176174
// Show which event we are currently presenting the results for.

examples/run/cuda/seq_example_cuda.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <vecmem/memory/cuda/host_memory_resource.hpp>
3131
#include <vecmem/memory/host_memory_resource.hpp>
3232
#include <vecmem/utils/cuda/async_copy.hpp>
33-
#include <vecmem/utils/cuda/copy.hpp>
3433

3534
// System include(s).
3635
#include <exception>
@@ -72,13 +71,12 @@ int seq_run(const traccc::full_tracking_input_config& i_cfg,
7271

7372
traccc::cuda::stream stream;
7473

75-
vecmem::cuda::copy copy;
76-
vecmem::cuda::async_copy async_copy{stream.cudaStream()};
74+
vecmem::cuda::async_copy copy{stream.cudaStream()};
7775

7876
traccc::cuda::clusterization_algorithm ca_cuda(
79-
mr, async_copy, stream, common_opts.target_cells_per_partition);
80-
traccc::cuda::seeding_algorithm sa_cuda(mr, async_copy, stream);
81-
traccc::cuda::track_params_estimation tp_cuda(mr, async_copy, stream);
77+
mr, copy, stream, common_opts.target_cells_per_partition);
78+
traccc::cuda::seeding_algorithm sa_cuda(mr, copy, stream);
79+
traccc::cuda::track_params_estimation tp_cuda(mr, copy, stream);
8280

8381
// performance writer
8482
traccc::seeding_performance_writer sd_performance_writer(
@@ -220,9 +218,9 @@ int seq_run(const traccc::full_tracking_input_config& i_cfg,
220218
traccc::seed_collection_types::host seeds_cuda;
221219
traccc::bound_track_parameters_collection_types::host params_cuda;
222220
if (run_cpu || i_cfg.check_performance) {
223-
copy(spacepoints_cuda_buffer, spacepoints_per_event_cuda);
224-
copy(seeds_cuda_buffer, seeds_cuda);
225-
copy(params_cuda_buffer, params_cuda);
221+
copy(spacepoints_cuda_buffer, spacepoints_per_event_cuda)->wait();
222+
copy(seeds_cuda_buffer, seeds_cuda)->wait();
223+
copy(params_cuda_buffer, params_cuda)->wait();
226224
}
227225

228226
if (run_cpu) {

examples/run/sycl/seeding_example_sycl.sycl

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ int seq_run(const traccc::seeding_input_config& i_cfg,
168168
// Copy the seeds to the host for comparison.
169169
traccc::seed_collection_types::host seeds_sycl;
170170
traccc::bound_track_parameters_collection_types::host params_sycl;
171-
copy(seeds_sycl_buffer, seeds_sycl);
172-
copy(params_sycl_buffer, params_sycl);
171+
copy(seeds_sycl_buffer, seeds_sycl)->wait();
172+
copy(params_sycl_buffer, params_sycl)->wait();
173173

174174
if (run_cpu && i_cfg.check_performance) {
175175
// Show which event we are currently presenting the results for.

examples/run/sycl/seq_example_sycl.sycl

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ int seq_run(const traccc::full_tracking_input_config& i_cfg,
242242
traccc::seed_collection_types::host seeds_sycl;
243243
traccc::bound_track_parameters_collection_types::host params_sycl;
244244
if (run_cpu || i_cfg.check_performance) {
245-
copy(spacepoints_sycl_buffer, spacepoints_per_event_sycl);
246-
copy(seeds_sycl_buffer, seeds_sycl);
247-
copy(params_sycl_buffer, params_sycl);
245+
copy(spacepoints_sycl_buffer, spacepoints_per_event_sycl)->wait();
246+
copy(seeds_sycl_buffer, seeds_sycl)->wait();
247+
copy(params_sycl_buffer, params_sycl)->wait();
248248
}
249249

250250
if (run_cpu) {

0 commit comments

Comments
 (0)