Skip to content

Commit 477c325

Browse files
committed
remove KOKKOS_LAMBDA
1 parent f8a58b6 commit 477c325

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/pcms/adapter/omega_h/omega_h_field2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend
3333
"data_d", data.size());
3434
Kokkos::deep_copy(data_d, Kokkos::View<const Real*, HostMemorySpace>(
3535
data.data_handle(), data.size()));
36-
Omega_h::parallel_for(
36+
Kokkos::parallel_for(
3737
mesh_.nents(dim), KOKKOS_CLASS_LAMBDA(size_t ent) {
3838
for (size_t n = 0; n < num_nodes; ++n) {
3939
for (size_t c = 0; c < num_components; ++c) {
@@ -51,7 +51,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend
5151
auto topo = static_cast<MeshField::Mesh_Topology>(dim);
5252
Kokkos::View<Real*, DefaultExecutionSpace::memory_space> data_d(
5353
"data_d", data.size());
54-
Omega_h::parallel_for(
54+
Kokkos::parallel_for(
5555
mesh_.nents(dim), KOKKOS_CLASS_LAMBDA(size_t ent) {
5656
for (size_t n = 0; n < num_nodes; ++n) {
5757
for (size_t c = 0; c < num_components; ++c) {

test/test_field_communication.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ void client1(MPI_Comm comm, Omega_h::Mesh& mesh, std::string comm_name,
7272
const auto n = layout->GetNumOwnedDofHolder();
7373
Omega_h::HostWrite<Real> ids(n);
7474
PCMS_ALWAYS_ASSERT(n == gids.size());
75-
for (size_t i = 0; i < static_cast<size_t>(n); ++i) {
76-
ids[i] = gids[i];
77-
}
75+
Kokkos::parallel_for(
76+
"id gid", Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, n),
77+
[=](int i) { ids[i] = gids[i]; });
7878

7979
auto field = layout->CreateField();
8080
field->SetDOFHolderData(pcms::make_const_array_view(ids));
@@ -157,9 +157,9 @@ void server(MPI_Comm comm, Omega_h::Mesh& mesh, std::string comm_name,
157157
pcms::CoordinateSystem::Cartesian);
158158
const auto n = layout->GetNumOwnedDofHolder();
159159
Omega_h::HostWrite<Real> ids(n);
160-
for (size_t i = 0; i < static_cast<size_t>(n); ++i) {
161-
ids[i] = 0;
162-
}
160+
Kokkos::parallel_for(
161+
"id 0", Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, n),
162+
[=](int i) { ids[i] = 0; });
163163

164164
auto field = layout->CreateField();
165165
pcms::FieldLayoutCommunicator<pcms::Real> layout_comm1(

test/test_field_copy.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ void test_copy(Omega_h::CommPtr world, int dim, int order, int num_components)
2323
pcms::CoordinateSystem::Cartesian);
2424
int ndata = layout->GetNumOwnedDofHolder() * num_components;
2525
Omega_h::HostWrite<Real> ids(ndata);
26-
for (size_t i = 0; i < static_cast<size_t>(ndata); ++i) {
27-
ids[i] = i;
28-
}
26+
Kokkos::parallel_for(
27+
Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, ndata),
28+
[=](int i) { ids[i] = i; });
2929

3030
auto original = layout->CreateField();
3131
original->SetDOFHolderData(pcms::make_const_array_view(ids));
@@ -36,11 +36,12 @@ void test_copy(Omega_h::CommPtr world, int dim, int order, int num_components)
3636

3737
REQUIRE(copied_array.size() == ndata);
3838
int sum = 0;
39-
for (size_t i = 0; i < static_cast<size_t>(ndata); ++i) {
40-
if (std::abs(ids[i] - copied_array[i]) < 1e-12) {
41-
sum++;
42-
}
43-
}
39+
Kokkos::parallel_reduce(
40+
Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, ndata),
41+
[=](int i, int& local_sum) {
42+
local_sum += std::abs(ids[i] - copied_array[i]) < 1e-12;
43+
},
44+
sum);
4445
REQUIRE(sum == ndata);
4546
}
4647

0 commit comments

Comments
 (0)