Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/ngp/UnitTestNgpDebugFieldSync_PartialAllocation.cpp

raw
1 // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
2 // Solutions of Sandia, LLC (NTESS). Under the terms of Contract
3 // DE-NA0003525 with NTESS, the U.S. Government retains certain rights
4 // in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // * Neither the name of NTESS nor the names of its contributors
19 // may be used to endorse or promote products derived from this
20 // software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34
35 #include <gtest/gtest.h>
36 #include "NgpDebugFieldSync_Fixtures.hpp"
37
38 namespace {
39
40 class NgpDebugFieldSync_PartialAllocation : public NgpDebugFieldSyncFixture
41 {
42 public:
43 template <typename T>
44 void write_scalar_field_on_device_using_entity_field_data(stk::mesh::Field<T> & stkField, T value)
45 {
46 const int component = 0;
47 stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk());
48 stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
49 stk::mesh::Selector fieldSelector(stkField);
50
51 stk::mesh::for_each_entity_run(ngpMesh, stk::topology::ELEM_RANK, fieldSelector,
52 KOKKOS_LAMBDA(const stk::mesh::FastMeshIndex& entity) {
53 #if defined(DEVICE_USE_LOCATION_BUILTINS)
54 stk::mesh::EntityFieldData<double> vals = ngpField(entity);
55 #else
56 stk::mesh::EntityFieldData<double> vals = ngpField(entity, __FILE__, __LINE__);
57 #endif
58 vals[component] = value;
59 });
60 }
61
62 template <typename T>
63 void write_scalar_field_on_device_using_mesh_index(stk::mesh::Field<T> & stkField, T value)
64 {
65 const int component = 0;
66 stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk());
67 stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
68 stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), stkField);
69 stk::mesh::EntityRank rank = ngpField.get_rank();
70
71 Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) {
72 for (unsigned i = 0; i < bucketIds.size(); ++i) {
73 const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i));
74 for (unsigned j = 0; j < bucket.size(); ++j) {
75 stk::mesh::NgpMesh::MeshIndex index{bucket.bucket_id(), static_cast<unsigned>(j)};
76 ngpField(index, component) = value;
77 }
78 }
79 });
80 }
81 };
82
83 TEST_F(NgpDebugFieldSync_PartialAllocation, FirstBlock_ScalarAccessUsingEntity_ProperlySyncToDevice_NoWarning)
84 {
85 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
86 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
87 create_parts({"Part1", "Part2"});
88 declare_scalar_field<double>("doubleScalarField", {"Part1"});
89 build_mesh({{"Part1", 2}, {"Part2", 2}});
90 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
91
92 testing::internal::CaptureStdout();
93 write_scalar_field_on_host_using_entity(stkField, 3.14);
94 stkField.modify_on_host();
95 stkField.sync_to_device();
96
97 read_scalar_field_on_device(stkField);
98
99 std::string stdoutString = testing::internal::GetCapturedStdout();
100 check_no_warnings(stdoutString);
101 }
102
103 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_ProperlySyncToDevice_NoWarning)
104 {
105 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
106 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
107 create_parts({"Part1", "Part2"});
108 declare_scalar_field<double>("doubleScalarField", {"Part2"});
109 build_mesh({{"Part1", 2}, {"Part2", 2}});
110 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
111
112 testing::internal::CaptureStdout();
113 write_scalar_field_on_host_using_entity(stkField, 3.14);
114 stkField.modify_on_host();
115 stkField.sync_to_device();
116
117 read_scalar_field_on_device(stkField);
118
119 std::string stdoutString = testing::internal::GetCapturedStdout();
120 check_no_warnings(stdoutString);
121 }
122
123 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MissingAllModifySyncCallsToDevice_Warning)
124 {
125 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
126 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
127 create_parts({"Part1", "Part2"});
128 declare_scalar_field<double>("doubleScalarField", {"Part2"});
129 build_mesh({{"Part1", 2}, {"Part2", 2}});
130 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
131
132 testing::internal::CaptureStdout();
133 write_scalar_field_on_host_using_entity(stkField, 3.14);
134
135 read_scalar_field_on_device(stkField);
136
137 std::string stdoutString = testing::internal::GetCapturedStdout();
138 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30");
139 check_no_warnings(stdoutString);
140 }
141
142 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntityFieldData_ProperlySyncToDevice_NoWarning)
143 {
144 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
145 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
146 create_parts({"Part1", "Part2"});
147 declare_scalar_field<double>("doubleScalarField", {"Part2"});
148 build_mesh({{"Part1", 2}, {"Part2", 2}});
149 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
150
151 testing::internal::CaptureStdout();
152 write_scalar_field_on_host_using_entity(stkField, 3.14);
153 stkField.modify_on_host();
154 stkField.sync_to_device();
155
156 read_field_on_device_using_entity_field_data(stkField);
157
158 std::string stdoutString = testing::internal::GetCapturedStdout();
159 check_no_warnings(stdoutString);
160 }
161
162 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntityFieldData_MissingAllModifySyncCallsToDevice_Warning)
163 {
164 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
165 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
166 create_parts({"Part1", "Part2"});
167 declare_scalar_field<double>("doubleScalarField", {"Part2"});
168 build_mesh({{"Part1", 2}, {"Part2", 2}});
169 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
170
171 testing::internal::CaptureStdout();
172 write_scalar_field_on_host_using_entity(stkField, 3.14);
173
174 read_field_on_device_using_entity_field_data(stkField);
175
176 std::string stdoutString = testing::internal::GetCapturedStdout();
177 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30");
178 check_no_warnings(stdoutString);
179 }
180
181 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingMeshIndex_ProperlySyncToDevice_NoWarning)
182 {
183 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
184 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
185 create_parts({"Part1", "Part2"});
186 declare_scalar_field<double>("doubleScalarField", {"Part2"});
187 build_mesh({{"Part1", 2}, {"Part2", 2}});
188 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
189
190 testing::internal::CaptureStdout();
191 write_scalar_field_on_host_using_entity(stkField, 3.14);
192 stkField.modify_on_host();
193 stkField.sync_to_device();
194
195 read_field_on_device_using_mesh_index(stkField);
196
197 std::string stdoutString = testing::internal::GetCapturedStdout();
198 check_no_warnings(stdoutString);
199 }
200
201 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingMeshIndex_MissingAllModifySyncCallsToDevice_Warning)
202 {
203 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
204 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
205 create_parts({"Part1", "Part2"});
206 declare_scalar_field<double>("doubleScalarField", {"Part2"});
207 build_mesh({{"Part1", 2}, {"Part2", 2}});
208 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
209
210 testing::internal::CaptureStdout();
211 write_scalar_field_on_host_using_entity(stkField, 3.14);
212
213 read_field_on_device_using_mesh_index(stkField);
214
215 std::string stdoutString = testing::internal::GetCapturedStdout();
216 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30");
217 check_no_warnings(stdoutString);
218 }
219
220
221 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_ProperlySyncToDevice_NoWarning)
222 {
223 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
224 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
225 create_parts({"Part1", "Part2", "Part3"});
226 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
227 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
228 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
229
230 testing::internal::CaptureStdout();
231 write_scalar_field_on_host_using_bucket(stkField, 3.14);
232 stkField.modify_on_host();
233 stkField.sync_to_device();
234
235 read_scalar_field_on_device(stkField);
236
237 std::string stdoutString = testing::internal::GetCapturedStdout();
238 check_no_warnings(stdoutString);
239 }
240
241 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MissingAllModifySyncCallsToDevice_Warning)
242 {
243 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
244 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
245 create_parts({"Part1", "Part2", "Part3"});
246 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
247 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
248 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
249
250 testing::internal::CaptureStdout();
251 write_scalar_field_on_host_using_bucket(stkField, 3.14);
252
253 read_scalar_field_on_device(stkField);
254
255 std::string stdoutString = testing::internal::GetCapturedStdout();
256 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20");
257 check_no_warnings(stdoutString);
258 }
259
260 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketId_ProperlySyncToDevice_NoWarning)
261 {
262 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
263 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
264 create_parts({"Part1", "Part2", "Part3"});
265 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
266 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
267 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
268
269 testing::internal::CaptureStdout();
270 write_scalar_field_on_host_using_bucket_id(stkField, 3.14);
271 stkField.modify_on_host();
272 stkField.sync_to_device();
273
274 read_scalar_field_on_device(stkField);
275
276 std::string stdoutString = testing::internal::GetCapturedStdout();
277 check_no_warnings(stdoutString);
278 }
279
280 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketId_MissingAllModifySyncCallsToDevice_Warning)
281 {
282 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
283 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
284 create_parts({"Part1", "Part2", "Part3"});
285 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
286 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
287 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
288
289 testing::internal::CaptureStdout();
290 write_scalar_field_on_host_using_bucket_id(stkField, 3.14);
291
292 read_scalar_field_on_device(stkField);
293
294 std::string stdoutString = testing::internal::GetCapturedStdout();
295 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20");
296 check_no_warnings(stdoutString);
297 }
298
299 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketIdAndOrdinal_ProperlySyncToDevice_NoWarning)
300 {
301 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
302 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
303 create_parts({"Part1", "Part2", "Part3"});
304 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
305 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
306 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
307
308 testing::internal::CaptureStdout();
309 write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14);
310 stkField.modify_on_host();
311 stkField.sync_to_device();
312
313 read_scalar_field_on_device(stkField);
314
315 std::string stdoutString = testing::internal::GetCapturedStdout();
316 check_no_warnings(stdoutString);
317 }
318
319 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketIdAndOrdinal_MissingAllModifySyncCallsToDevice_Warning)
320 {
321 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
322 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
323 create_parts({"Part1", "Part2", "Part3"});
324 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
325 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
326 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
327
328 testing::internal::CaptureStdout();
329 write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14);
330
331 read_scalar_field_on_device(stkField);
332
333 std::string stdoutString = testing::internal::GetCapturedStdout();
334 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20");
335 check_no_warnings(stdoutString);
336 }
337
338 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketIdAndOrdinalAndSize_ProperlySyncToDevice_NoWarning)
339 {
340 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
341 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
342 create_parts({"Part1", "Part2", "Part3"});
343 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
344 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
345 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
346
347 testing::internal::CaptureStdout();
348 write_scalar_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14);
349 stkField.modify_on_host();
350 stkField.sync_to_device();
351
352 read_scalar_field_on_device(stkField);
353
354 std::string stdoutString = testing::internal::GetCapturedStdout();
355 check_no_warnings(stdoutString);
356 }
357
358 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucketIdAndOrdinalAndSize_MissingAllModifySyncCallsToDevice_Warning)
359 {
360 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
361 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
362 create_parts({"Part1", "Part2", "Part3"});
363 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
364 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
365 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
366
367 testing::internal::CaptureStdout();
368 write_scalar_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14);
369
370 read_scalar_field_on_device(stkField);
371
372 std::string stdoutString = testing::internal::GetCapturedStdout();
373 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20");
374 check_no_warnings(stdoutString);
375 }
376
377
378 TEST_F(NgpDebugFieldSync_PartialAllocation, FirstBlock_ScalarAccessUsingEntity_ProperlySyncToHost_NoWarning)
379 {
380 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
381 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
382 create_parts({"Part1", "Part2"});
383 declare_scalar_field<double>("doubleScalarField", {"Part1"});
384 build_mesh({{"Part1", 2}, {"Part2", 2}});
385 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
386
387 testing::internal::CaptureStdout();
388 write_scalar_field_on_host_using_entity(stkField, 3.14);
389 stkField.modify_on_host();
390 stkField.sync_to_device();
391
392 read_scalar_field_on_device(stkField);
393
394 std::string stdoutString = testing::internal::GetCapturedStdout();
395 check_no_warnings(stdoutString);
396 }
397
398 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_ProperlySyncToHost_NoWarning)
399 {
400 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
401 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
402 create_parts({"Part1", "Part2", "Part3"});
403 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
404 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
405 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
406
407 testing::internal::CaptureStdout();
408 write_scalar_field_on_device(stkField, 3.14);
409 stkField.modify_on_device();
410 stkField.sync_to_host();
411
412 read_scalar_field_on_host_using_entity(stkField);
413
414 std::string stdoutString = testing::internal::GetCapturedStdout();
415 check_no_warnings(stdoutString);
416 }
417
418 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MissingAllModifySyncCallsToHost_Warning)
419 {
420 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
421 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
422 create_parts({"Part1", "Part2", "Part3"});
423 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
424 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
425 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
426
427 testing::internal::CaptureStdout();
428 write_scalar_field_on_device(stkField, 3.14);
429
430 read_scalar_field_on_host_using_entity(stkField);
431
432 std::string stdoutString = testing::internal::GetCapturedStdout();
433 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
434 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
435 check_no_warnings(stdoutString);
436 }
437
438 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_DeviceEntityFieldDataAccess_ProperlySyncToHost_NoWarning)
439 {
440 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
441 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
442 create_parts({"Part1", "Part2", "Part3"});
443 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
444 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
445 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
446
447 testing::internal::CaptureStdout();
448 write_scalar_field_on_device_using_entity_field_data(stkField, 3.14);
449 stkField.modify_on_device();
450 stkField.sync_to_host();
451
452 read_scalar_field_on_host_using_entity(stkField);
453 std::string stdoutString = testing::internal::GetCapturedStdout();
454 check_no_warnings(stdoutString);
455 }
456
457 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_DeviceEntityFieldDataAccess_MissingAllModifySyncCallsToHost_Warning)
458 {
459 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
460 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
461 create_parts({"Part1", "Part2", "Part3"});
462 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
463 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
464 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
465
466 testing::internal::CaptureStdout();
467 write_scalar_field_on_device_using_entity_field_data(stkField, 3.14);
468
469 read_scalar_field_on_host_using_entity(stkField);
470
471 std::string stdoutString = testing::internal::GetCapturedStdout();
472 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
473 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
474 check_no_warnings(stdoutString);
475 }
476
477 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_DeviceMeshIndexAccess_ProperlySyncToHost_NoWarning)
478 {
479 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
480 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
481 create_parts({"Part1", "Part2", "Part3"});
482 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
483 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
484 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
485
486 testing::internal::CaptureStdout();
487 write_scalar_field_on_device_using_mesh_index(stkField, 3.14);
488 stkField.modify_on_device();
489 stkField.sync_to_host();
490
491 read_scalar_field_on_host_using_entity(stkField);
492
493 std::string stdoutString = testing::internal::GetCapturedStdout();
494 check_no_warnings(stdoutString);
495 }
496
497 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_DeviceMeshIndexAccess_MissingAllModifySyncCallsToHost_Warning)
498 {
499 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
500 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
501 create_parts({"Part1", "Part2", "Part3"});
502 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
503 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
504 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
505
506 testing::internal::CaptureStdout();
507 write_scalar_field_on_device_using_mesh_index(stkField, 3.14);
508
509 read_scalar_field_on_host_using_entity(stkField);
510
511 std::string stdoutString = testing::internal::GetCapturedStdout();
512 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
513 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
514 check_no_warnings(stdoutString);
515 }
516
517 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_ProperlySyncToHost_NoWarning)
518 {
519 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
520 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
521 create_parts({"Part1", "Part2", "Part3"});
522 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
523 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
524 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
525
526 testing::internal::CaptureStdout();
527 write_scalar_field_on_device(stkField, 3.14);
528 stkField.modify_on_device();
529 stkField.sync_to_host();
530
531 read_scalar_field_on_host_using_bucket(stkField);
532
533 std::string stdoutString = testing::internal::GetCapturedStdout();
534 check_no_warnings(stdoutString);
535 }
536
537 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MissingAllModifySyncCallsToHost_Warning)
538 {
539 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
540 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
541 create_parts({"Part1", "Part2", "Part3"});
542 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
543 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
544 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
545
546 testing::internal::CaptureStdout();
547 write_scalar_field_on_device(stkField, 3.14);
548
549 read_scalar_field_on_host_using_bucket(stkField);
550 std::string stdoutString = testing::internal::GetCapturedStdout();
551 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
552 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
553 check_no_warnings(stdoutString);
554 }
555
556
557 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarWriteOnHost_ProperlyMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning)
558 {
559 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
560 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
561 create_parts({"Part1", "Part2"});
562 declare_scalar_field<double>("doubleScalarField", {"Part2"});
563 build_mesh({{"Part1", 2}, {"Part2", 2}});
564 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
565
566 testing::internal::CaptureStdout();
567 write_scalar_field_on_host_using_entity(stkField, 3.14);
568 stkField.modify_on_host();
569 stkField.clear_sync_state();
570
571 read_scalar_field_on_device(stkField);
572
573 std::string stdoutString = testing::internal::GetCapturedStdout();
574 check_no_warnings(stdoutString);
575 }
576
577 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarWriteOnHost_ProperlyMarkAsModified_ClearHostSyncState_AccessOnDevice_NoWarning)
578 {
579 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
580 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
581 create_parts({"Part1", "Part2"});
582 declare_scalar_field<double>("doubleScalarField", {"Part2"});
583 build_mesh({{"Part1", 2}, {"Part2", 2}});
584 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
585
586 testing::internal::CaptureStdout();
587 write_scalar_field_on_host_using_entity(stkField, 3.14);
588 stkField.modify_on_host();
589 stkField.clear_host_sync_state();
590
591 read_scalar_field_on_device(stkField);
592
593 std::string stdoutString = testing::internal::GetCapturedStdout();
594 check_no_warnings(stdoutString);
595 }
596
597 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarWriteOnDevice_ProperlyMarkAsModified_ClearSyncState_AccessOnHost_NoWarning)
598 {
599 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
600 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
601 create_parts({"Part1", "Part2", "Part3"});
602 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
603 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
604 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
605
606 testing::internal::CaptureStdout();
607 write_scalar_field_on_device(stkField, 3.14);
608 stkField.modify_on_device();
609 stkField.clear_sync_state();
610
611 read_scalar_field_on_host_using_entity(stkField);
612
613 std::string stdoutString = testing::internal::GetCapturedStdout();
614 check_no_warnings(stdoutString);
615 }
616
617 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarWriteOnDevice_ProperlyMarkAsModified_ClearDeviceSyncState_AccessOnHost_NoWarning)
618 {
619 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
620 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
621 create_parts({"Part1", "Part2", "Part3"});
622 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
623 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
624 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
625
626 testing::internal::CaptureStdout();
627 write_scalar_field_on_device(stkField, 3.14);
628 stkField.modify_on_device();
629 stkField.clear_device_sync_state();
630
631 read_scalar_field_on_host_using_entity(stkField);
632
633 std::string stdoutString = testing::internal::GetCapturedStdout();
634 check_no_warnings(stdoutString);
635 }
636
637
638 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarDeviceSetAll_AccessOnHost_Warning)
639 {
640 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
641 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
642 create_parts({"Part1", "Part2", "Part3"});
643 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
644 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
645 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
646
647 testing::internal::CaptureStdout();
648 device_field_set_all(stkField, 2.18);
649
650 read_scalar_field_on_host_using_entity(stkField);
651
652 std::string stdoutString = testing::internal::GetCapturedStdout();
653 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
654 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
655 check_no_warnings(stdoutString);
656 }
657
658 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarDeviceSetAll_AccessOnDevice_NoWarning)
659 {
660 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
661 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
662 create_parts({"Part1", "Part2"});
663 declare_scalar_field<double>("doubleScalarField", {"Part2"});
664 build_mesh({{"Part1", 2}, {"Part2", 2}});
665 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
666
667 testing::internal::CaptureStdout();
668 device_field_set_all(stkField, 2.18);
669
670 read_scalar_field_on_device(stkField);
671
672 std::string stdoutString = testing::internal::GetCapturedStdout();
673 check_no_warnings(stdoutString);
674 }
675
676 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarDeviceSetAll_MissingAllModifySyncCallsToDevice_Warning)
677 {
678 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
679 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
680 create_parts({"Part1", "Part2"});
681 declare_scalar_field<double>("doubleScalarField", {"Part2"});
682 build_mesh({{"Part1", 2}, {"Part2", 2}});
683 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
684
685 testing::internal::CaptureStdout();
686 write_scalar_field_on_host_using_entity(stkField, 3.14);
687
688 device_field_set_all(stkField, 2.18);
689
690 std::string stdoutString = testing::internal::GetCapturedStdout();
691 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]");
692 check_no_warnings(stdoutString);
693 }
694
695 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarDeviceSetAll_MissingAllModifySyncCallsToHost_AccessOnHost_Warning)
696 {
697 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
698 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
699 create_parts({"Part1", "Part2", "Part3"});
700 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
701 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
702 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
703
704 testing::internal::CaptureStdout();
705 write_scalar_field_on_device(stkField, 3.14);
706
707 device_field_set_all(stkField, 2.18);
708
709 read_scalar_field_on_host_using_entity(stkField);
710
711 std::string stdoutString = testing::internal::GetCapturedStdout();
712 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
713 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
714 check_no_warnings(stdoutString);
715 }
716
717 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarDeviceSetAll_MissingAllModifySyncCallsToHost_AccessOnDevice_NoWarning)
718 {
719 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
720 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
721 create_parts({"Part1", "Part2"});
722 declare_scalar_field<double>("doubleScalarField", {"Part2"});
723 build_mesh({{"Part1", 2}, {"Part2", 2}});
724 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
725
726 testing::internal::CaptureStdout();
727 write_scalar_field_on_device(stkField, 3.14);
728
729 device_field_set_all(stkField, 2.18);
730
731 read_scalar_field_on_device(stkField);
732
733 std::string stdoutString = testing::internal::GetCapturedStdout();
734 check_no_warnings(stdoutString);
735 }
736
737
738 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_ProperlySyncToDevice_NoWarning)
739 {
740 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
741 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
742 create_parts({"Part1", "Part2"});
743 declare_scalar_field<double>("doubleScalarField", {"Part2"});
744 build_mesh({{"Part1", 2}, {"Part2", 2}});
745 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
746
747 testing::internal::CaptureStdout();
748
749 const size_t numTimeSteps = 2;
750 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
751 write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep);
752 stkField.modify_on_host();
753 stkField.sync_to_device();
754 read_scalar_field_on_device(stkField);
755 }
756
757 std::string stdoutString = testing::internal::GetCapturedStdout();
758 check_no_warnings(stdoutString);
759 }
760
761 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_MissingAllModifySyncCallsToDevice_Warning)
762 {
763 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
764 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
765 create_parts({"Part1", "Part2"});
766 declare_scalar_field<double>("doubleScalarField", {"Part2"});
767 build_mesh({{"Part1", 2}, {"Part2", 2}});
768 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
769
770 testing::internal::CaptureStdout();
771
772 const size_t numTimeSteps = 2;
773 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
774 write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep);
775 read_scalar_field_on_device(stkField);
776 }
777
778 std::string stdoutString = testing::internal::GetCapturedStdout();
779 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30");
780 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=40");
781 check_no_warnings(stdoutString);
782 }
783
784 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_ProperlyMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning)
785 {
786 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
787 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
788 create_parts({"Part1", "Part2"});
789 declare_scalar_field<double>("doubleScalarField", {"Part2"});
790 build_mesh({{"Part1", 2}, {"Part2", 2}});
791 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
792
793 testing::internal::CaptureStdout();
794
795 const size_t numTimeSteps = 2;
796 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
797 write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep);
798 stkField.modify_on_host();
799 stkField.clear_sync_state();
800 read_scalar_field_on_device(stkField);
801 }
802
803 std::string stdoutString = testing::internal::GetCapturedStdout();
804 check_no_warnings(stdoutString);
805 }
806
807 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleAccesses_ProperlySyncToDevice_NoWarning)
808 {
809 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
810 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
811 create_parts({"Part1", "Part2"});
812 declare_scalar_field<double>("doubleScalarField", {"Part2"});
813 build_mesh({{"Part1", 2}, {"Part2", 2}});
814 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
815
816 testing::internal::CaptureStdout();
817
818 write_scalar_field_on_host_using_entity(stkField, 3.14);
819 stkField.modify_on_host();
820 stkField.sync_to_device();
821
822 read_scalar_field_on_device(stkField);
823 read_scalar_field_on_device(stkField);
824
825 std::string stdoutString = testing::internal::GetCapturedStdout();
826 check_no_warnings(stdoutString);
827 }
828
829 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleStaleAccesses_MissingAllModifySyncCallsToDevice_Warning)
830 {
831 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
832 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
833 create_parts({"Part1", "Part2"});
834 declare_scalar_field<double>("doubleScalarField", {"Part2"});
835 build_mesh({{"Part1", 2}, {"Part2", 2}});
836 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
837
838 testing::internal::CaptureStdout();
839
840 write_scalar_field_on_host_using_entity(stkField, 3.14);
841
842 read_scalar_field_on_device(stkField);
843 read_scalar_field_on_device(stkField);
844
845 std::string stdoutString = testing::internal::GetCapturedStdout();
846 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30.000000");
847 check_no_warnings(stdoutString);
848 }
849
850 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleWrites_ProperlySyncToDevice_NoWarning)
851 {
852 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
853 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
854 create_parts({"Part1", "Part2"});
855 declare_scalar_field<double>("doubleScalarField", {"Part2"});
856 build_mesh({{"Part1", 2}, {"Part2", 2}});
857 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
858
859 testing::internal::CaptureStdout();
860
861 write_scalar_field_on_host_using_entity(stkField, 3.14);
862 write_scalar_field_on_host_using_entity(stkField, 2.18);
863 stkField.modify_on_host();
864 stkField.sync_to_device();
865
866 read_scalar_field_on_device(stkField);
867
868 std::string stdoutString = testing::internal::GetCapturedStdout();
869 check_no_warnings(stdoutString);
870 }
871
872 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleWrites_MissingAllModifySyncCallsToDevice_Warning)
873 {
874 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
875 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
876 create_parts({"Part1", "Part2"});
877 declare_scalar_field<double>("doubleScalarField", {"Part2"});
878 build_mesh({{"Part1", 2}, {"Part2", 2}});
879 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
880
881 testing::internal::CaptureStdout();
882
883 write_scalar_field_on_host_using_entity(stkField, 3.14);
884 write_scalar_field_on_host_using_entity(stkField, 2.18);
885
886 read_scalar_field_on_device(stkField);
887
888 std::string stdoutString = testing::internal::GetCapturedStdout();
889 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30.000000");
890 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=40.000000");
891 check_no_warnings(stdoutString);
892 }
893
894
895 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleTimestep_ProperlySyncToDevice_NoWarning)
896 {
897 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
898 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
899 create_parts({"Part1", "Part2", "Part3"});
900 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
901 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
902 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
903
904 testing::internal::CaptureStdout();
905
906 const size_t numTimeSteps = 2;
907 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
908 write_scalar_field_on_host_using_bucket(stkField, 3.14+timeStep);
909 stkField.modify_on_host();
910 stkField.sync_to_device();
911 read_scalar_field_on_device(stkField);
912 }
913
914 std::string stdoutString = testing::internal::GetCapturedStdout();
915 check_no_warnings(stdoutString);
916 }
917
918 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleTimestep_MissingAllModifySyncCallsToDevice_Warning)
919 {
920 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
921 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
922 create_parts({"Part1", "Part2", "Part3"});
923 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
924 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
925 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
926
927 testing::internal::CaptureStdout();
928
929 const size_t numTimeSteps = 2;
930 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
931 write_scalar_field_on_host_using_bucket(stkField, 3.14+timeStep);
932 read_scalar_field_on_device(stkField);
933 }
934
935 std::string stdoutString = testing::internal::GetCapturedStdout();
936 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20.000000");
937 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30.000000");
938 check_no_warnings(stdoutString);
939 }
940
941 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleAccesses_ProperlySyncToDevice_NoWarning)
942 {
943 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
944 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
945 create_parts({"Part1", "Part2", "Part3"});
946 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
947 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
948 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
949
950 testing::internal::CaptureStdout();
951
952 write_scalar_field_on_host_using_bucket(stkField, 3.14);
953 stkField.modify_on_host();
954 stkField.sync_to_device();
955
956 read_scalar_field_on_device(stkField);
957 read_scalar_field_on_device(stkField);
958
959 std::string stdoutString = testing::internal::GetCapturedStdout();
960 check_no_warnings(stdoutString);
961 }
962
963 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleStaleAccesses_MissingAllModifySyncCallsToDevice_Warning)
964 {
965 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
966 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
967 create_parts({"Part1", "Part2", "Part3"});
968 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
969 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
970 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
971
972 testing::internal::CaptureStdout();
973
974 write_scalar_field_on_host_using_bucket(stkField, 3.14);
975
976 read_scalar_field_on_device(stkField);
977 read_scalar_field_on_device(stkField);
978
979 std::string stdoutString = testing::internal::GetCapturedStdout();
980 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20.000000");
981 check_no_warnings(stdoutString);
982 }
983
984 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleWrites_ProperlySyncToDevice_NoWarning)
985 {
986 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
987 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
988 create_parts({"Part1", "Part2"});
989 declare_scalar_field<double>("doubleScalarField", {"Part2"});
990 build_mesh({{"Part1", 2}, {"Part2", 2}});
991 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
992
993 testing::internal::CaptureStdout();
994
995 write_scalar_field_on_host_using_bucket(stkField, 3.14);
996 write_scalar_field_on_host_using_bucket(stkField, 2.18);
997 stkField.modify_on_host();
998 stkField.sync_to_device();
999
1000 read_scalar_field_on_device(stkField);
1001
1002 std::string stdoutString = testing::internal::GetCapturedStdout();
1003 check_no_warnings(stdoutString);
1004 }
1005
1006 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleWrites_MissingAllModifySyncCallsToDevice_Warning)
1007 {
1008 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1009 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1010 create_parts({"Part1", "Part2"});
1011 declare_scalar_field<double>("doubleScalarField", {"Part2"});
1012 build_mesh({{"Part1", 2}, {"Part2", 2}});
1013 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1014
1015 testing::internal::CaptureStdout();
1016
1017 write_scalar_field_on_host_using_bucket(stkField, 3.14);
1018 write_scalar_field_on_host_using_bucket(stkField, 2.18);
1019
1020 read_scalar_field_on_device(stkField);
1021
1022 std::string stdoutString = testing::internal::GetCapturedStdout();
1023 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=30.000000");
1024 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=40.000000");
1025 check_no_warnings(stdoutString);
1026 }
1027
1028
1029 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_ProperlySyncToHost_NoWarning)
1030 {
1031 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1032 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1033 create_parts({"Part1", "Part2", "Part3"});
1034 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1035 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1036 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1037
1038 testing::internal::CaptureStdout();
1039
1040 const size_t numTimeSteps = 2;
1041 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
1042 write_scalar_field_on_device(stkField, 3.14+timeStep);
1043 stkField.modify_on_device();
1044 stkField.sync_to_host();
1045 read_scalar_field_on_host_using_entity(stkField);
1046 }
1047
1048 std::string stdoutString = testing::internal::GetCapturedStdout();
1049 check_no_warnings(stdoutString);
1050 }
1051
1052 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_MissingAllModifySyncCallsToHost_Warning)
1053 {
1054 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1055 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1056 create_parts({"Part1", "Part2", "Part3"});
1057 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1058 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1059 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1060
1061 testing::internal::CaptureStdout();
1062
1063 const size_t numTimeSteps = 2;
1064 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
1065 write_scalar_field_on_device(stkField, 3.14+timeStep);
1066 read_scalar_field_on_host_using_entity(stkField);
1067 }
1068
1069 std::string stdoutString = testing::internal::GetCapturedStdout();
1070 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1071 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1072 check_no_warnings(stdoutString);
1073 }
1074
1075 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleTimestep_ProperlyMarkAsModified_ClearSyncState_AccessOnHost_NoWarning)
1076 {
1077 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1078 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1079 create_parts({"Part1", "Part2", "Part3"});
1080 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1081 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1082 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1083
1084 testing::internal::CaptureStdout();
1085
1086 const size_t numTimeSteps = 2;
1087 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
1088 write_scalar_field_on_device(stkField, 3.14+timeStep);
1089 stkField.modify_on_device();
1090 stkField.clear_sync_state();
1091 read_scalar_field_on_host_using_entity(stkField);
1092 }
1093
1094 std::string stdoutString = testing::internal::GetCapturedStdout();
1095 check_no_warnings(stdoutString);
1096 }
1097
1098 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleAccesses_ProperlySyncToHost_NoWarning)
1099 {
1100 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1101 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1102 create_parts({"Part1", "Part2", "Part3"});
1103 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1104 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1105 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1106
1107 testing::internal::CaptureStdout();
1108
1109 write_scalar_field_on_device(stkField, 3.14);
1110 stkField.modify_on_device();
1111 stkField.sync_to_host();
1112
1113 read_scalar_field_on_host_using_entity(stkField);
1114 read_scalar_field_on_host_using_entity(stkField);
1115
1116 std::string stdoutString = testing::internal::GetCapturedStdout();
1117 check_no_warnings(stdoutString);
1118 }
1119
1120 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleStaleAccesses_MissingAllModifySyncCallsToHost_Warning)
1121 {
1122 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1123 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1124 create_parts({"Part1", "Part2", "Part3"});
1125 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1126 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1127 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1128
1129 testing::internal::CaptureStdout();
1130
1131 write_scalar_field_on_device(stkField, 3.14);
1132
1133 read_scalar_field_on_host_using_entity(stkField);
1134 read_scalar_field_on_host_using_entity(stkField);
1135
1136 std::string stdoutString = testing::internal::GetCapturedStdout();
1137 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1138 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1139 check_no_warnings(stdoutString);
1140 }
1141
1142 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleWrites_ProperlySyncToHost_NoWarning)
1143 {
1144 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1145 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1146 create_parts({"Part1", "Part2", "Part3"});
1147 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1148 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1149 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1150
1151 testing::internal::CaptureStdout();
1152
1153 write_scalar_field_on_device(stkField, 3.14);
1154 write_scalar_field_on_device(stkField, 2.18);
1155 stkField.modify_on_device();
1156 stkField.sync_to_host();
1157
1158 read_scalar_field_on_host_using_entity(stkField);
1159
1160 std::string stdoutString = testing::internal::GetCapturedStdout();
1161 check_no_warnings(stdoutString);
1162 }
1163
1164 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MultipleWrites_MissingAllModifySyncCallsToHost_Warning)
1165 {
1166 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1167 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1168 create_parts({"Part1", "Part2", "Part3"});
1169 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1170 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1171 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1172
1173 testing::internal::CaptureStdout();
1174
1175 write_scalar_field_on_device(stkField, 3.14);
1176 write_scalar_field_on_device(stkField, 2.18);
1177
1178 read_scalar_field_on_host_using_entity(stkField);
1179
1180 std::string stdoutString = testing::internal::GetCapturedStdout();
1181 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1182 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1183 check_no_warnings(stdoutString);
1184 }
1185
1186
1187 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleTimestep_ProperlySyncToHost_NoWarning)
1188 {
1189 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1190 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1191 create_parts({"Part1", "Part2", "Part3"});
1192 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1193 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1194 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1195
1196 testing::internal::CaptureStdout();
1197
1198 const size_t numTimeSteps = 2;
1199 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
1200 write_scalar_field_on_device(stkField, 3.14+timeStep);
1201 stkField.modify_on_device();
1202 stkField.sync_to_host();
1203 read_scalar_field_on_host_using_bucket(stkField);
1204 }
1205
1206 std::string stdoutString = testing::internal::GetCapturedStdout();
1207 check_no_warnings(stdoutString);
1208 }
1209
1210 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleTimestep_MissingAllModifySyncCallsToHost_Warning)
1211 {
1212 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1213 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1214 create_parts({"Part1", "Part2", "Part3"});
1215 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1216 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1217 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1218
1219 testing::internal::CaptureStdout();
1220
1221 const size_t numTimeSteps = 2;
1222 for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) {
1223 write_scalar_field_on_device(stkField, 3.14+timeStep);
1224 read_scalar_field_on_host_using_bucket(stkField);
1225 }
1226
1227 std::string stdoutString = testing::internal::GetCapturedStdout();
1228 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1229 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1230 check_no_warnings(stdoutString);
1231 }
1232
1233 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleAccesses_ProperlySyncToHost_NoWarning)
1234 {
1235 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1236 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1237 create_parts({"Part1", "Part2", "Part3"});
1238 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1239 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1240 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1241
1242 testing::internal::CaptureStdout();
1243
1244 write_scalar_field_on_device(stkField, 3.14);
1245 stkField.modify_on_device();
1246 stkField.sync_to_host();
1247
1248 read_scalar_field_on_host_using_bucket(stkField);
1249 read_scalar_field_on_host_using_bucket(stkField);
1250
1251 std::string stdoutString = testing::internal::GetCapturedStdout();
1252 check_no_warnings(stdoutString);
1253 }
1254
1255 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleStaleAccesses_MissingAllModifySyncCallsToHost_Warning)
1256 {
1257 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1258 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1259 create_parts({"Part1", "Part2", "Part3"});
1260 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1261 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1262 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1263
1264 testing::internal::CaptureStdout();
1265
1266 write_scalar_field_on_device(stkField, 3.14);
1267
1268 read_scalar_field_on_host_using_bucket(stkField);
1269 read_scalar_field_on_host_using_bucket(stkField);
1270
1271 std::string stdoutString = testing::internal::GetCapturedStdout();
1272 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1273 extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1274 check_no_warnings(stdoutString);
1275 }
1276
1277 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleWrites_ProperlySyncToHost_NoWarning)
1278 {
1279 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1280 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1281 create_parts({"Part1", "Part2", "Part3"});
1282 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1283 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1284 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1285
1286 testing::internal::CaptureStdout();
1287
1288 write_scalar_field_on_device(stkField, 3.14);
1289 write_scalar_field_on_device(stkField, 2.18);
1290 stkField.modify_on_device();
1291 stkField.sync_to_host();
1292
1293 read_scalar_field_on_host_using_bucket(stkField);
1294
1295 std::string stdoutString = testing::internal::GetCapturedStdout();
1296 check_no_warnings(stdoutString);
1297 }
1298
1299 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingBucket_MultipleWrites_MissingAllModifySyncCallsToHost_Warning)
1300 {
1301 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1302 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1303 create_parts({"Part1", "Part2", "Part3"});
1304 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1305 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 1}});
1306 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1307
1308 testing::internal::CaptureStdout();
1309
1310 write_scalar_field_on_device(stkField, 3.14);
1311 write_scalar_field_on_device(stkField, 2.18);
1312
1313 read_scalar_field_on_host_using_bucket(stkField);
1314
1315 std::string stdoutString = testing::internal::GetCapturedStdout();
1316 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20");
1317 extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=30");
1318 check_no_warnings(stdoutString);
1319 }
1320
1321
1322 TEST_F(NgpDebugFieldSync_PartialAllocation, EmptyField_MeshModification_ProperlySyncToDevice_NoWarning)
1323 {
1324 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1325 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1326 create_parts({"Part1", "Part2", "Part3"});
1327 get_meta().enable_field_sync_debugger();
1328 get_meta().declare_field<double>(stk::topology::ELEM_RANK, "doubleScalarField", 1);
1329 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1330 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1331
1332 testing::internal::CaptureStdout();
1333 get_bulk().modification_begin();
1334 get_bulk().modification_end();
1335
1336 stkField.modify_on_host();
1337 stkField.sync_to_device();
1338
1339 read_scalar_field_on_device(stkField);
1340
1341 std::string stdoutString = testing::internal::GetCapturedStdout();
1342 check_no_warnings(stdoutString);
1343 }
1344
1345 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_ProperlySyncToDevice_NoWarning)
1346 {
1347 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1348 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1349 create_parts({"Part1", "Part2", "Part3"});
1350 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1351 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1352 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1353
1354 testing::internal::CaptureStdout();
1355 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1356
1357 write_scalar_field_on_host_using_entity(stkField, 3.14);
1358 stkField.modify_on_host();
1359 stkField.sync_to_device();
1360
1361 read_scalar_field_on_device(stkField);
1362
1363 std::string stdoutString = testing::internal::GetCapturedStdout();
1364 check_no_warnings(stdoutString);
1365 }
1366
1367 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_ClearSyncState_AccessOnDevice_NoWarning)
1368 {
1369 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1370 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1371 create_parts({"Part1", "Part2", "Part3"});
1372 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1373 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1374 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1375
1376 testing::internal::CaptureStdout();
1377 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1378
1379 write_scalar_field_on_host_using_entity(stkField, 3.14);
1380 stkField.modify_on_host();
1381 stkField.clear_sync_state();
1382
1383 read_scalar_field_on_device(stkField);
1384
1385 std::string stdoutString = testing::internal::GetCapturedStdout();
1386 check_no_warnings(stdoutString);
1387 }
1388
1389 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_MissingAllModifySyncCallsToDevice_NoWarning)
1390 {
1391 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1392 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1393 create_parts({"Part1", "Part2", "Part3"});
1394 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1395 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1396 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1397
1398 testing::internal::CaptureStdout();
1399
1400 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1401 write_scalar_field_on_host_using_entity(stkField, 3.14);
1402 read_scalar_field_on_device(stkField);
1403
1404 std::string stdoutString = testing::internal::GetCapturedStdout();
1405 check_no_warnings(stdoutString);
1406 }
1407
1408
1409 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_ProperlySyncToDevice_NoWarning)
1410 {
1411 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1412 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1413 create_parts({"Part1", "Part2", "Part3"});
1414 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1415 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1416 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1417
1418 testing::internal::CaptureStdout();
1419 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1420 stkField.modify_on_host();
1421 stkField.sync_to_device();
1422
1423 read_scalar_field_on_device(stkField);
1424
1425 std::string stdoutString = testing::internal::GetCapturedStdout();
1426 check_no_warnings(stdoutString);
1427 }
1428
1429 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_MissingAllModifySyncCallsToDevice_NoWarning)
1430 {
1431 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1432 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1433 create_parts({"Part1", "Part2", "Part3"});
1434 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1435 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1436 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1437
1438 testing::internal::CaptureStdout();
1439
1440 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1441 read_scalar_field_on_device(stkField);
1442
1443 std::string stdoutString = testing::internal::GetCapturedStdout();
1444 check_no_warnings(stdoutString);
1445 }
1446
1447
1448 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_ProperlySyncToHost_NoWarning)
1449 {
1450 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1451 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1452 create_parts({"Part1", "Part2", "Part3"});
1453 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1454 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1455 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1456
1457 testing::internal::CaptureStdout();
1458
1459 write_scalar_field_on_device(stkField, 3.14);
1460 stkField.modify_on_device();
1461 stkField.sync_to_host();
1462
1463 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1464
1465 read_scalar_field_on_host_using_entity(stkField);
1466
1467 std::string stdoutString = testing::internal::GetCapturedStdout();
1468 check_no_warnings(stdoutString);
1469 }
1470
1471 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_ClearSyncState_NoWarning)
1472 {
1473 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1474 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1475 create_parts({"Part1", "Part2", "Part3"});
1476 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1477 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1478 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1479
1480 testing::internal::CaptureStdout();
1481
1482 write_scalar_field_on_device(stkField, 3.14);
1483 stkField.modify_on_device();
1484 stkField.clear_sync_state();
1485
1486 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1487
1488 read_scalar_field_on_host_using_entity(stkField);
1489
1490 std::string stdoutString = testing::internal::GetCapturedStdout();
1491 check_no_warnings(stdoutString);
1492 }
1493
1494 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_MissingAllModifySyncCallsToHost_Warning)
1495 {
1496 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1497 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1498 create_parts({"Part1", "Part2", "Part3"});
1499 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1500 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1501 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1502
1503 testing::internal::CaptureStdout();
1504
1505 write_scalar_field_on_device(stkField, 3.14);
1506 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1507 read_scalar_field_on_host_using_entity(stkField);
1508
1509 std::string stdoutString = testing::internal::GetCapturedStdout();
1510 extract_warning(stdoutString, 2, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host");
1511 check_no_warnings(stdoutString);
1512 }
1513
1514
1515 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_ProperlySyncToHost_NoWarning)
1516 {
1517 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1518 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1519 create_parts({"Part1", "Part2", "Part3"});
1520 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1521 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1522 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1523
1524 testing::internal::CaptureStdout();
1525
1526 write_scalar_field_on_device(stkField, 3.14);
1527 stkField.modify_on_device();
1528 stkField.sync_to_host();
1529
1530 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1531
1532 std::string stdoutString = testing::internal::GetCapturedStdout();
1533 check_no_warnings(stdoutString);
1534 }
1535
1536 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_MissingAllModifySyncCallsToHost_Warning)
1537 {
1538 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1539 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1540 create_parts({"Part1", "Part2", "Part3"});
1541 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1542 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1543 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1544
1545 testing::internal::CaptureStdout();
1546
1547 write_scalar_field_on_device(stkField, 3.14);
1548 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1549
1550 std::string stdoutString = testing::internal::GetCapturedStdout();
1551 extract_warning(stdoutString, 4, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host");
1552 check_no_warnings(stdoutString);
1553 }
1554
1555
1556 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_MissingDeviceFieldUpdate_AccessOnDevice_Warning)
1557 {
1558 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1559 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1560 create_parts({"Part1", "Part2", "Part3"});
1561 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1562 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1563 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1564 stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
1565
1566 testing::internal::CaptureStdout();
1567 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1568
1569 write_scalar_field_on_host_using_entity(stkField, 3.14);
1570
1571 read_old_scalar_field_on_device(stkField, ngpField);
1572
1573 std::string stdoutString = testing::internal::GetCapturedStdout();
1574 extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification");
1575 check_no_warnings(stdoutString);
1576 }
1577
1578 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_MissingDeviceFieldUpdate_AccessOnDevice_Warning)
1579 {
1580 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1581 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1582 create_parts({"Part1", "Part2", "Part3"});
1583 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1584 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1585 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1586 stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
1587
1588 testing::internal::CaptureStdout();
1589 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1590
1591 read_old_scalar_field_on_device(stkField, ngpField);
1592
1593 std::string stdoutString = testing::internal::GetCapturedStdout();
1594 extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification");
1595 check_no_warnings(stdoutString);
1596 }
1597
1598
1599 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_MoveBucketOffField_StaleDeviceFieldCopy_AccessOnDevice_Warning)
1600 {
1601 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1602 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1603 create_parts({"Part1", "Part2", "Part3"});
1604 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1605 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1606 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1607 stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
1608
1609 testing::internal::CaptureStdout();
1610 modify_element_part_membership({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}});
1611
1612 write_scalar_field_on_host_using_entity(stkField, 3.14);
1613 stkField.modify_on_host();
1614 stkField.sync_to_device();
1615
1616 read_old_scalar_field_on_device(stkField, ngpFieldCopy);
1617
1618 std::string stdoutString = testing::internal::GetCapturedStdout();
1619 extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification");
1620 check_no_warnings(stdoutString);
1621 }
1622
1623 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_MeshModification_Batch_Empty_MoveBucketOffField_StaleDeviceFieldCopy_AccessOnDevice_Warning)
1624 {
1625 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1626 const unsigned bucketCapacity = 1;
1627 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity);
1628 create_parts({"Part1", "Part2", "Part3"});
1629 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1630 build_mesh({{"Part1", 1}, {"Part2", 2}});
1631 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1632 stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
1633
1634 testing::internal::CaptureStdout();
1635 batch_modify_element_part_membership({{3, "Part3", "Part2"}});
1636 get_bulk().modification_begin();
1637 get_bulk().modification_end();
1638
1639 write_scalar_field_on_host_using_entity(stkField, 3.14);
1640 stkField.modify_on_host();
1641 stkField.sync_to_device();
1642
1643 read_old_scalar_field_on_device(stkField, ngpFieldCopy);
1644
1645 std::string stdoutString = testing::internal::GetCapturedStdout();
1646 extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification");
1647 check_no_warnings(stdoutString);
1648 }
1649
1650 TEST_F(NgpDebugFieldSync_PartialAllocation, SecondBlock_ScalarAccessUsingEntity_DuringMeshModification_MoveBucketOffField_StaleDeviceFieldCopy_AccessOnDevice_Warning)
1651 {
1652 if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return;
1653 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
1654 create_parts({"Part1", "Part2", "Part3"});
1655 declare_scalar_field<double>("doubleScalarField", {"Part2", "Part3"});
1656 build_mesh({{"Part1", 1}, {"Part2", 1}, {"Part3", 3}});
1657 stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField");
1658 stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField);
1659
1660 testing::internal::CaptureStdout();
1661 modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part1", "Part2"}, {3, "Part1", "Part3"}}, stkField, 3.14);
1662 stkField.modify_on_host();
1663 stkField.sync_to_device();
1664
1665 read_old_scalar_field_on_device(stkField, ngpFieldCopy);
1666
1667 std::string stdoutString = testing::internal::GetCapturedStdout();
1668 extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification");
1669 check_no_warnings(stdoutString);
1670 }
1671
1672 }