Skip to content

Commit 27691a3

Browse files
fix errors
1 parent 79d06bd commit 27691a3

4 files changed

Lines changed: 37 additions & 39 deletions

File tree

src/engines/engine.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ namespace ntt {
6161
#else
6262
adios2::ADIOS m_adios;
6363
#endif
64-
#endif
6564
#endif // OUTPUT_ENABLED
6665

6766
SimulationParams m_params;

src/framework/containers/particles.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,20 @@ namespace ntt {
7575
-> std::pair<std::vector<std::size_t>, array_t<std::size_t*>> {
7676
auto this_tag = tag;
7777
const auto num_tags = ntags();
78-
array_t<std::size_t*> npptag { "nparts_per_tag", ntags() };
78+
std::vector<std::size_t> npptag_vec;
7979

8080
// count # of particles per each tag
81-
auto npptag_scat = Kokkos::Experimental::create_scatter_view(npptag);
82-
Kokkos::parallel_for(
83-
"NpartPerTag",
84-
rangeActiveParticles(),
85-
Lambda(index_t p) {
86-
auto npptag_acc = npptag_scat.access();
87-
if (this_tag(p) < 0 || this_tag(p) >= num_tags) {
88-
raise::KernelError(HERE, "Invalid tag value");
89-
}
90-
npptag_acc(this_tag(p)) += 1;
91-
});
92-
Kokkos::Experimental::contribute(npptag, npptag_scat);
93-
94-
// copy the count to a vector on the host
95-
auto npptag_h = Kokkos::create_mirror_view(npptag);
96-
Kokkos::deep_copy(npptag_h, npptag);
97-
std::vector<std::size_t> npptag_vec(num_tags);
98-
for (auto t { 0u }; t < num_tags; ++t) {
99-
npptag_vec[t] = npptag_h(t);
81+
for (std::size_t t { 0 }; t < ntags(); ++t) {
82+
std::size_t npart_tag = 0;
83+
Kokkos::parallel_reduce(
84+
"NpartPerTag",
85+
npart(),
86+
Lambda(index_t p, std::size_t& loc_npart_tag) {
87+
if (this_tag(p) == t) {
88+
loc_npart_tag++;
89+
}
90+
}, npart_tag);
91+
npptag_vec.push_back(npart_tag);
10092
}
10193

10294
// count the offsets on the host and copy to device

src/framework/domain/comm_mpi.hpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ namespace comm {
143143
}
144144
if (send_rank >= 0) {
145145
if constexpr (D == Dim::_1D) {
146-
auto host_send_fld = ndarray_mirror_t<2>("send_fld",
146+
send_fld = ndarray_t<2>("send_fld",
147147
send_slice[0].second - send_slice[0].first,
148148
comps.second - comps.first);
149149
Kokkos::deep_copy(send_fld, Kokkos::subview(fld, send_slice[0], comps));
150150
} else if constexpr (D == Dim::_2D) {
151-
auto host_send_fld = ndarray_mirror_t<3>("send_fld",
151+
send_fld = ndarray_t<3>("send_fld",
152152
send_slice[0].second - send_slice[0].first,
153153
send_slice[1].second - send_slice[1].first,
154154
comps.second - comps.first);
155155
Kokkos::deep_copy(
156156
send_fld,
157157
Kokkos::subview(fld, send_slice[0], send_slice[1], comps));
158158
} else if constexpr (D == Dim::_3D) {
159-
auto host_send_fld = ndarray_mirror_t<4>("send_fld",
159+
send_fld = ndarray_t<4>("send_fld",
160160
send_slice[0].second - send_slice[0].first,
161161
send_slice[1].second - send_slice[1].first,
162162
send_slice[2].second - send_slice[2].first,
@@ -168,22 +168,26 @@ namespace comm {
168168
}
169169
if (recv_rank >= 0) {
170170
if constexpr (D == Dim::_1D) {
171-
host_recv_fld = ndarray_mirror_t<2>("recv_fld",
171+
recv_fld = ndarray_t<2>("recv_fld",
172172
recv_slice[0].second - recv_slice[0].first,
173173
comps.second - comps.first);
174174
} else if constexpr (D == Dim::_2D) {
175-
host_recv_fld = ndarray_mirror_t<3>("recv_fld",
175+
recv_fld = ndarray_t<3>("recv_fld",
176176
recv_slice[0].second - recv_slice[0].first,
177177
recv_slice[1].second - recv_slice[1].first,
178178
comps.second - comps.first);
179179
} else if constexpr (D == Dim::_3D) {
180-
host_recv_fld = ndarray_mirror_t<4>("recv_fld",
180+
recv_fld = ndarray_t<4>("recv_fld",
181181
recv_slice[0].second - recv_slice[0].first,
182182
recv_slice[1].second - recv_slice[1].first,
183183
recv_slice[2].second - recv_slice[2].first,
184184
comps.second - comps.first);
185185
}
186186
}
187+
auto host_send_fld = Kokkos::create_mirror_view(send_fld);
188+
auto host_recv_fld = Kokkos::create_mirror_view(recv_fld);
189+
190+
Kokkos::deep_copy(host_send_fld, send_fld);
187191

188192
if (send_rank >= 0 && recv_rank >= 0) {
189193
MPI_Sendrecv(host_send_fld.data(),
@@ -198,6 +202,8 @@ namespace comm {
198202
0,
199203
MPI_COMM_WORLD,
200204
MPI_STATUS_IGNORE);
205+
206+
Kokkos::deep_copy(recv_fld, host_recv_fld);
201207
} else if (send_rank >= 0) {
202208
MPI_Send(host_send_fld.data(),
203209
nsend,
@@ -214,6 +220,8 @@ namespace comm {
214220
0,
215221
MPI_COMM_WORLD,
216222
MPI_STATUS_IGNORE);
223+
224+
Kokkos::deep_copy(recv_fld, host_recv_fld);
217225
} else {
218226
raise::Error("CommunicateField called with negative ranks", HERE);
219227
}
@@ -223,16 +231,15 @@ namespace comm {
223231
// !TODO: perhaps directly recv to the fld?
224232
if (not additive) {
225233
if constexpr (D == Dim::_1D) {
226-
Kokkos::deep_copy(Kokkos::subview(fld, recv_slice[0], comps), host_recv_fld);
234+
Kokkos::deep_copy(Kokkos::subview(fld, recv_slice[0], comps), recv_fld);
227235
} else if constexpr (D == Dim::_2D) {
228236
Kokkos::deep_copy(
229-
Kokkos::subview(fld, recv_slice[0], recv_slice[1], comps), host_recv_fld);
237+
Kokkos::subview(fld, recv_slice[0], recv_slice[1], comps), recv_fld);
230238
} else if constexpr (D == Dim::_3D) {
231239
Kokkos::deep_copy(
232-
Kokkos::subview(fld, recv_slice[0], recv_slice[1], recv_slice[2], comps), host_recv_fld);
240+
Kokkos::subview(fld, recv_slice[0], recv_slice[1], recv_slice[2], comps), recv_fld);
233241
}
234242
} else {
235-
auto recv_fld = Kokkos::create_mirror_view(host_recv_fld);
236243
Kokkos::deep_copy(recv_fld, host_recv_fld);
237244
if constexpr (D == Dim::_1D) {
238245
const auto offset_x1 = recv_slice[0].first;

src/output/writer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <mpi.h>
1919
#endif
2020

21-
#include <filesystem>
21+
#include <experimental/filesystem>
2222
#include <string>
2323
#include <vector>
2424

@@ -440,13 +440,13 @@ namespace out {
440440
}
441441
CallOnce(
442442
[](auto& main_path, auto& mode_path) {
443-
const std::filesystem::path main { main_path };
444-
const std::filesystem::path mode { mode_path };
445-
if (!std::filesystem::exists(main_path)) {
446-
std::filesystem::create_directory(main_path);
443+
const std::experimental::filesystem::path main { main_path };
444+
const std::experimental::filesystem::path mode { mode_path };
445+
if (!std::experimental::filesystem::exists(main_path)) {
446+
std::experimental::filesystem::create_directory(main_path);
447447
}
448-
if (!std::filesystem::exists(main / mode)) {
449-
std::filesystem::create_directory(main / mode);
448+
if (!std::experimental::filesystem::exists(main / mode)) {
449+
std::experimental::filesystem::create_directory(main / mode);
450450
}
451451
},
452452
m_fname,
@@ -460,7 +460,7 @@ namespace out {
460460
m_mode = adios2::Mode::Write;
461461
} else {
462462
filename = fmt::format("%s.%s", m_fname.c_str(), ext.c_str());
463-
m_mode = std::filesystem::exists(filename) ? adios2::Mode::Append
463+
m_mode = std::experimental::filesystem::exists(filename) ? adios2::Mode::Append
464464
: adios2::Mode::Write;
465465
}
466466
m_writer = m_io.Open(filename, m_mode);

0 commit comments

Comments
 (0)