Skip to content

Commit 5d90722

Browse files
authored
Merge pull request #251 from Sichao25/yus/debug_gpu_warning
Resolve compiler warnings when building with CUDA
2 parents bae226d + 95cd841 commit 5d90722

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

src/pcms/adapter/omega_h/omega_h_field2.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ 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(
37-
mesh_.nents(dim), OMEGA_H_LAMBDA(size_t ent) {
36+
Kokkos::parallel_for(
37+
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) {
4040
shape_field_(ent, n, c, topo) =
@@ -51,8 +51,8 @@ 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(
55-
mesh_.nents(dim), OMEGA_H_LAMBDA(size_t ent) {
54+
Kokkos::parallel_for(
55+
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) {
5858
data_d[ent * stride + n * num_components + c] =
@@ -122,6 +122,7 @@ struct FillCoordinatesAndIndicesFunctor
122122
Kokkos::View<Real**> coordinates_;
123123
Kokkos::View<LO*> indices_;
124124
Kokkos::View<GridPointSearch::Result*> search_results_;
125+
Omega_h::Int dim_;
125126

126127
FillCoordinatesAndIndicesFunctor(
127128
Omega_h::Mesh& mesh, Kokkos::View<LO*> elem_counts,
@@ -133,21 +134,23 @@ struct FillCoordinatesAndIndicesFunctor
133134
offsets_(offsets),
134135
coordinates_(coordinates),
135136
indices_(indices),
136-
search_results_(search_results)
137+
search_results_(search_results),
138+
dim_(mesh.dim())
137139
{
138140
}
139141

140142
KOKKOS_INLINE_FUNCTION
141143
void operator()(LO i) const
142144
{
143145
auto [dim, elem_idx, coord] = search_results_(i);
146+
// disable the host assertion macro for device code
144147
// currently don't handle case where point is on a boundary
145-
PCMS_ALWAYS_ASSERT(static_cast<int>(dim) == mesh_.dim());
148+
// PCMS_ALWAYS_ASSERT(static_cast<int>(dim) == mesh_.dim());
146149
// element should be inside the domain (positive)
147-
PCMS_ALWAYS_ASSERT(elem_idx >= 0 && elem_idx < mesh_.nelems());
150+
// PCMS_ALWAYS_ASSERT(elem_idx >= 0 && elem_idx < mesh_.nelems());
148151
LO count = Kokkos::atomic_sub_fetch(&elem_counts_(elem_idx), 1);
149152
LO index = offsets_(elem_idx) + count - 1;
150-
for (int j = 0; j < (mesh_.dim() + 1); ++j) {
153+
for (int j = 0; j < (dim_ + 1); ++j) {
151154
coordinates_(index, j) = coord[j];
152155
}
153156
indices_(index) = i;

src/pcms/adapter/point_cloud/point_cloud.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void PointCloud::SetDOFHolderData(Rank1View<const Real, HostMemorySpace> data)
5858
PCMS_ALWAYS_ASSERT(data.size() == data_.size());
5959
Kokkos::parallel_for(
6060
Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, data.size()),
61-
KOKKOS_LAMBDA(int i) { data_host_(i) = data[i]; });
61+
KOKKOS_CLASS_LAMBDA(int i) { data_host_(i) = data[i]; });
6262
Kokkos::deep_copy(data_, data_host_);
6363
}
6464

@@ -100,7 +100,7 @@ int PointCloud::Serialize(
100100
if (buffer.size() > 0) {
101101
Kokkos::parallel_for(
102102
data_.size(),
103-
KOKKOS_LAMBDA(int i) { buffer[permutation[i]] = data_(i); });
103+
KOKKOS_CLASS_LAMBDA(int i) { buffer[permutation[i]] = data_(i); });
104104
}
105105
return data_.size();
106106
}
@@ -111,7 +111,8 @@ void PointCloud::Deserialize(
111111
{
112112
PCMS_FUNCTION_TIMER;
113113
Kokkos::parallel_for(
114-
data_.size(), KOKKOS_LAMBDA(int i) { data_(i) = buffer[permutation[i]]; });
114+
data_.size(),
115+
KOKKOS_CLASS_LAMBDA(int i) { data_(i) = buffer[permutation[i]]; });
115116
}
116117

117118
} // namespace pcms

src/pcms/field_layout_communicator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ redev::LOs ConstructPermutation(GlobalIDView<HostMemorySpace> local_gids,
118118
break;
119119
}
120120

121-
LO local_index = 0;
122121
redev::LOs permutation;
123122
permutation.reserve(local_gids.size());
124123
for (int e = 0; e < ent_offsets.size() - 1; ++e) {

test/test_field_communication.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void client1(MPI_Comm comm, Omega_h::Mesh& mesh, std::string comm_name,
7474
PCMS_ALWAYS_ASSERT(n == gids.size());
7575
Kokkos::parallel_for(
7676
"id gid", Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, n),
77-
KOKKOS_LAMBDA(int i) { ids[i] = gids[i]; });
77+
[=](int i) { ids[i] = gids[i]; });
7878

7979
auto field = layout->CreateField();
8080
field->SetDOFHolderData(pcms::make_const_array_view(ids));
@@ -159,7 +159,7 @@ void server(MPI_Comm comm, Omega_h::Mesh& mesh, std::string comm_name,
159159
Omega_h::HostWrite<Real> ids(n);
160160
Kokkos::parallel_for(
161161
"id 0", Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, n),
162-
KOKKOS_LAMBDA(int i) { ids[i] = 0; });
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void test_copy(Omega_h::CommPtr world, int dim, int order, int num_components)
2525
Omega_h::HostWrite<Real> ids(ndata);
2626
Kokkos::parallel_for(
2727
Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, ndata),
28-
KOKKOS_LAMBDA(int i) { ids[i] = i; });
28+
[=](int i) { ids[i] = i; });
2929

3030
auto original = layout->CreateField();
3131
original->SetDOFHolderData(pcms::make_const_array_view(ids));
@@ -38,7 +38,7 @@ void test_copy(Omega_h::CommPtr world, int dim, int order, int num_components)
3838
int sum = 0;
3939
Kokkos::parallel_reduce(
4040
Kokkos::RangePolicy<pcms::HostMemorySpace::execution_space>(0, ndata),
41-
KOKKOS_LAMBDA(int i, int& local_sum) {
41+
[=](int i, int& local_sum) {
4242
local_sum += std::abs(ids[i] - copied_array[i]) < 1e-12;
4343
},
4444
sum);

test/test_interpolation_on_ltx_mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ TEST_CASE("Test Interpolation on LTX Mesh", "[interpolation]")
245245
output_xgc_vtu_filename.c_str());
246246

247247
// ------------------ Verification ------------------ //
248-
double tol = 10.0 / 100.0; // 10 percent tolerance
248+
// double tol = 10.0 / 100.0; // 10 percent tolerance
249249
// XGC Originated Values
250250
/*
251251
for (int i = 0; i < xgc_num_nodes; ++i) {

0 commit comments

Comments
 (0)