| 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 <stk_mesh/base/Ngp.hpp> |
| 37 |
#include <stk_unit_test_utils/getOption.h> |
| 38 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 39 |
#include <stk_unit_test_utils/GetMeshSpec.hpp> |
| 40 |
#include <stk_unit_test_utils/PerformanceTester.hpp> |
| 41 |
#include <stk_mesh/base/MetaData.hpp> |
| 42 |
#include <stk_mesh/base/BulkData.hpp> |
| 43 |
#include <stk_mesh/base/Bucket.hpp> |
| 44 |
#include <stk_mesh/base/Field.hpp> |
| 45 |
#include <stk_mesh/base/Entity.hpp> |
| 46 |
#include <stk_mesh/base/GetEntities.hpp> |
| 47 |
#include <stk_mesh/base/GetNgpField.hpp> |
| 48 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 49 |
#include <stk_mesh/base/Comm.hpp> |
| 50 |
#include <stk_mesh/base/NgpFieldSyncDebugger.hpp> |
| 51 |
#include <stk_util/stk_config.h> |
| 52 |
#include "NgpDebugFieldSync_Fixtures.hpp" |
| 53 |
#include <string> |
| 54 |
#include <sstream> |
| 55 |
#include <vector> |
| 56 |
#include <numeric> |
| 57 |
|
| 58 |
namespace { |
| 59 |
|
| 60 |
class NgpDebugFieldSync : public NgpDebugFieldSyncFixture |
| 61 |
{ |
| 62 |
public: |
| 63 |
template <typename T> |
| 64 |
void initialize_ngp_field_default_debugger(stk::mesh::Field<T> & stkField) |
| 65 |
{ |
| 66 |
stk::mesh::get_updated_ngp_field<T>(stkField); |
| 67 |
} |
| 68 |
|
| 69 |
void set_initial_part_membership(const std::vector<std::pair<unsigned, std::string>> & numElemsInEachPart) |
| 70 |
{ |
| 71 |
get_bulk().modification_begin(); |
| 72 |
stk::mesh::EntityId elemId = 0; |
| 73 |
for (const auto & elemCountAndPart : numElemsInEachPart) { |
| 74 |
stk::mesh::PartVector addParts {get_meta().get_part(elemCountAndPart.second)}; |
| 75 |
stk::mesh::EntityVector elemsToChange; |
| 76 |
for (unsigned elemNum = 0; elemNum < elemCountAndPart.first; ++elemNum) { |
| 77 |
stk::mesh::Entity element = get_bulk().get_entity(stk::topology::ELEM_RANK, ++elemId); |
| 78 |
STK_ThrowRequireMsg(get_bulk().is_valid(element), "Invalid element in fixture!"); |
| 79 |
elemsToChange.push_back(element); |
| 80 |
} |
| 81 |
get_bulk().change_entity_parts(elemsToChange, addParts); |
| 82 |
} |
| 83 |
get_bulk().modification_end(); |
| 84 |
} |
| 85 |
|
| 86 |
template <typename T> |
| 87 |
void write_scalar_field_on_host_using_entity_default_debugger(stk::mesh::Field<T> & stkField, T value) |
| 88 |
{ |
| 89 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 90 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 91 |
for (const stk::mesh::Entity & entity : *bucket) { |
| 92 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>>(stkField, entity); |
| 93 |
fieldData[0] = value; |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
template <typename T> |
| 99 |
void write_vector_field_on_host_using_bucket_id_and_ordinal(stk::mesh::Field<T> & stkField, T value) |
| 100 |
{ |
| 101 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 102 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 103 |
for (const stk::mesh::Entity & entity : *bucket) { |
| 104 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, entity); |
| 105 |
fieldData[1] = value; // Write to second component only |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
template <typename T> |
| 111 |
void write_vector_field_on_host_using_bucket_id_and_ordinal_and_size(stk::mesh::Field<T> & stkField, T value) |
| 112 |
{ |
| 113 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 114 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 115 |
for (const stk::mesh::Entity & entity : *bucket) { |
| 116 |
const stk::mesh::MeshIndex & meshIndex = get_bulk().mesh_index(entity); |
| 117 |
const unsigned bucketId = meshIndex.bucket->bucket_id(); |
| 118 |
const stk::mesh::Bucket::size_type bucketOrd = meshIndex.bucket_ordinal; |
| 119 |
const unsigned numBytesPerEntity = stk::mesh::field_bytes_per_entity(stkField, *bucket); |
| 120 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucketId, bucketOrd, numBytesPerEntity); |
| 121 |
fieldData[1] = value; // Write to second component only |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
template <typename T> |
| 127 |
void write_vector_field_on_host_using_bucket(stk::mesh::Field<T> & stkField, T value) |
| 128 |
{ |
| 129 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 130 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 131 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, *bucket); |
| 132 |
for(size_t iEntity = 0; iEntity < bucket->size(); ++iEntity) { |
| 133 |
const size_t yComponent = iEntity*3 + 1; |
| 134 |
fieldData[yComponent] = value; |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
template <typename T> |
| 140 |
void write_vector_field_on_host_using_bucket_id(stk::mesh::Field<T> & stkField, T value) |
| 141 |
{ |
| 142 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 143 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 144 |
const unsigned bucketId = bucket->bucket_id(); |
| 145 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucketId); |
| 146 |
for(size_t iEntity = 0; iEntity < bucket->size(); ++iEntity) { |
| 147 |
const size_t yComponent = iEntity*3 + 1; |
| 148 |
fieldData[yComponent] = value; |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
template <typename T> |
| 154 |
void read_scalar_field_on_host_using_entity_default_debugger(stk::mesh::Field<T> & stkField) |
| 155 |
{ |
| 156 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 157 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 158 |
for (const stk::mesh::Entity & entity : *bucket) { |
| 159 |
const T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>>(stkField, entity); |
| 160 |
access_for_memory_checking_tool(fieldData); |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
template <typename T> |
| 166 |
void read_vector_field_on_host_using_bucket(stk::mesh::Field<T> & stkField) |
| 167 |
{ |
| 168 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 169 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 170 |
const T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, *bucket); |
| 171 |
access_for_memory_checking_tool(fieldData, bucket->size()*3); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
template <typename T, template <typename, typename> class NgpDebugger = stk::mesh::DefaultNgpFieldSyncDebugger> |
| 176 |
void write_scalar_host_field_on_device(stk::mesh::HostField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & hostField, T value) |
| 177 |
{ |
| 178 |
const int component = 0; |
| 179 |
stk::mesh::HostMesh hostMesh(get_bulk()); |
| 180 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 181 |
|
| 182 |
stk::mesh::for_each_entity_run(hostMesh, stk::topology::ELEM_RANK, meta.locally_owned_part(), |
| 183 |
KOKKOS_LAMBDA(const stk::mesh::FastMeshIndex& entity) { |
| 184 |
hostField(entity, component) = value; |
| 185 |
}); |
| 186 |
} |
| 187 |
|
| 188 |
template <typename T> |
| 189 |
void write_scalar_field_on_device_default_debugger(stk::mesh::Field<T> & stkField, T value) |
| 190 |
{ |
| 191 |
const int component = 0; |
| 192 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 193 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 194 |
stk::mesh::NgpField<T> & ngpField = stk::mesh::get_updated_ngp_field<T>(stkField); |
| 195 |
|
| 196 |
stk::mesh::for_each_entity_run(ngpMesh, stk::topology::ELEM_RANK, meta.locally_owned_part(), |
| 197 |
KOKKOS_LAMBDA(const stk::mesh::FastMeshIndex& entity) { |
| 198 |
ngpField(entity, component) = value; |
| 199 |
}); |
| 200 |
} |
| 201 |
|
| 202 |
template <typename T> |
| 203 |
void write_vector_field_on_device_using_mesh_index(stk::mesh::Field<T> & stkField, T value) |
| 204 |
{ |
| 205 |
const int component = 1; // Just write to the second component |
| 206 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 207 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 208 |
stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 209 |
stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), meta.locally_owned_part()); |
| 210 |
stk::mesh::EntityRank rank = ngpField.get_rank(); |
| 211 |
|
| 212 |
Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) { |
| 213 |
for (unsigned i = 0; i < bucketIds.size(); ++i) { |
| 214 |
const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i)); |
| 215 |
for (unsigned j = 0; j < bucket.size(); ++j) { |
| 216 |
stk::mesh::NgpMesh::MeshIndex index{bucket.bucket_id(), static_cast<unsigned>(j)}; |
| 217 |
ngpField(index, component) = value; |
| 218 |
} |
| 219 |
} |
| 220 |
}); |
| 221 |
} |
| 222 |
|
| 223 |
template <typename T> |
| 224 |
void write_vector_field_on_device_using_entity_field_data(stk::mesh::Field<T> & stkField, T value) |
| 225 |
{ |
| 226 |
const int component = 1; // Just write to the second component |
| 227 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 228 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 229 |
stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 230 |
|
| 231 |
stk::mesh::for_each_entity_run(ngpMesh, stk::topology::ELEM_RANK, meta.locally_owned_part(), |
| 232 |
KOKKOS_LAMBDA(const stk::mesh::FastMeshIndex& entity) { |
| 233 |
#if defined(DEVICE_USE_LOCATION_BUILTINS) |
| 234 |
stk::mesh::EntityFieldData<double> vals = ngpField(entity); |
| 235 |
#else |
| 236 |
stk::mesh::EntityFieldData<double> vals = ngpField(entity, __FILE__, __LINE__); |
| 237 |
#endif |
| 238 |
vals[component] = value; |
| 239 |
}); |
| 240 |
} |
| 241 |
|
| 242 |
template <typename T> |
| 243 |
void read_scalar_field_on_device_default_debugger(stk::mesh::Field<T> & stkField) |
| 244 |
{ |
| 245 |
const int component = 0; |
| 246 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 247 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 248 |
stk::mesh::NgpField<T> & ngpField = stk::mesh::get_updated_ngp_field<T>(stkField); |
| 249 |
stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), meta.locally_owned_part()); |
| 250 |
stk::mesh::EntityRank rank = ngpField.get_rank(); |
| 251 |
|
| 252 |
Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) { |
| 253 |
for (unsigned i = 0; i < bucketIds.size(); ++i) { |
| 254 |
const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i)); |
| 255 |
for (unsigned j = 0; j < bucket.size(); ++j) { |
| 256 |
stk::mesh::FastMeshIndex index = ngpMesh.fast_mesh_index(bucket[j]); |
| 257 |
#if defined(DEVICE_USE_LOCATION_BUILTINS) |
| 258 |
access_for_memory_checking_tool(&ngpField(index, component)); |
| 259 |
#else |
| 260 |
access_for_memory_checking_tool(&ngpField(index, component, __FILE__, __LINE__)); |
| 261 |
#endif |
| 262 |
} |
| 263 |
} |
| 264 |
}); |
| 265 |
} |
| 266 |
|
| 267 |
template <typename T> |
| 268 |
void read_vector_field_on_device(stk::mesh::Field<T> & stkField) |
| 269 |
{ |
| 270 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 271 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 272 |
stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 273 |
stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), meta.locally_owned_part()); |
| 274 |
stk::mesh::EntityRank rank = ngpField.get_rank(); |
| 275 |
|
| 276 |
Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) { |
| 277 |
for (unsigned i = 0; i < bucketIds.size(); ++i) { |
| 278 |
const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i)); |
| 279 |
for (unsigned j = 0; j < bucket.size(); ++j) { |
| 280 |
stk::mesh::FastMeshIndex index = ngpMesh.fast_mesh_index(bucket[j]); |
| 281 |
unsigned numComponents = ngpField.get_num_components_per_entity(index); |
| 282 |
for (unsigned component = 0; component < numComponents; ++component) { |
| 283 |
#if defined(DEVICE_USE_LOCATION_BUILTINS) |
| 284 |
access_for_memory_checking_tool(&ngpField(index, component)); |
| 285 |
#else |
| 286 |
access_for_memory_checking_tool(&ngpField(index, component, __FILE__, __LINE__)); |
| 287 |
#endif |
| 288 |
} |
| 289 |
} |
| 290 |
} |
| 291 |
}); |
| 292 |
} |
| 293 |
|
| 294 |
template <typename T, typename NGPFIELD> |
| 295 |
void read_old_scalar_field_on_device(stk::mesh::Field<T> & stkField, NGPFIELD & ngpField, |
| 296 |
stk::mesh::EntityId maxIdToRead = std::numeric_limits<stk::mesh::EntityId>::max()) |
| 297 |
{ |
| 298 |
const int component = 0; |
| 299 |
const stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 300 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 301 |
stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), meta.locally_owned_part()); |
| 302 |
stk::mesh::EntityRank rank = ngpField.get_rank(); |
| 303 |
|
| 304 |
Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) { |
| 305 |
for (unsigned i = 0; i < bucketIds.size(); ++i) { |
| 306 |
const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i)); |
| 307 |
for (unsigned j = 0; j < bucket.size(); ++j) { |
| 308 |
stk::mesh::FastMeshIndex index = ngpMesh.fast_mesh_index(bucket[j]); |
| 309 |
const stk::mesh::Entity elem = ngpMesh.get_entity(stk::topology::ELEM_RANK, index); |
| 310 |
const stk::mesh::EntityId elemId = ngpMesh.identifier(elem); |
| 311 |
if (elemId <= maxIdToRead) { |
| 312 |
#if defined(DEVICE_USE_LOCATION_BUILTINS) |
| 313 |
access_for_memory_checking_tool(&ngpField(index, component)); |
| 314 |
#else |
| 315 |
access_for_memory_checking_tool(&ngpField(index, component, __FILE__, __LINE__)); |
| 316 |
#endif |
| 317 |
} |
| 318 |
} |
| 319 |
} |
| 320 |
}); |
| 321 |
} |
| 322 |
|
| 323 |
void delete_element(const std::vector<stk::mesh::EntityId> & elemIds) |
| 324 |
{ |
| 325 |
get_bulk().modification_begin(); |
| 326 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 327 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 328 |
} |
| 329 |
get_bulk().modification_end(); |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
template <typename T> |
| 335 |
stk::mesh::Field<T> & create_scalar_field(stk::topology::rank_t rank, const std::string & name) |
| 336 |
{ |
| 337 |
get_meta().enable_field_sync_debugger(); |
| 338 |
unsigned numStates = 1; |
| 339 |
const T init = 1; |
| 340 |
stk::mesh::Field<T> & field = get_meta().declare_field<T>(rank, name, numStates); |
| 341 |
stk::mesh::put_field_on_mesh(field, get_meta().universal_part(), &init); |
| 342 |
return field; |
| 343 |
} |
| 344 |
|
| 345 |
template <typename T> |
| 346 |
stk::mesh::Field<T> & create_scalar_multistate_field(stk::topology::rank_t rank, const std::string & name) |
| 347 |
{ |
| 348 |
get_meta().enable_field_sync_debugger(); |
| 349 |
unsigned numStates = 2; |
| 350 |
const T init = 1; |
| 351 |
stk::mesh::Field<T> & field = get_meta().declare_field<T>(rank, name, numStates); |
| 352 |
stk::mesh::put_field_on_mesh(field, get_meta().universal_part(), &init); |
| 353 |
return field; |
| 354 |
} |
| 355 |
|
| 356 |
template <typename T> |
| 357 |
stk::mesh::Field<T> & create_vector_field(stk::topology::rank_t rank, const std::string & name) |
| 358 |
{ |
| 359 |
get_meta().enable_field_sync_debugger(); |
| 360 |
unsigned numStates = 1; |
| 361 |
unsigned numScalarsPerEntity = 3; |
| 362 |
const T init[] = {1, 2, 3}; |
| 363 |
stk::mesh::Field<T> & field = get_meta().declare_field<T>(rank, name, numStates); |
| 364 |
stk::mesh::put_field_on_mesh(field, get_meta().universal_part(), numScalarsPerEntity, init); |
| 365 |
return field; |
| 366 |
} |
| 367 |
|
| 368 |
void |
| 369 |
create_parts(const std::vector<std::pair<unsigned, std::string>> & numElemsInEachPart) |
| 370 |
{ |
| 371 |
for (const auto & elemCountAndPart : numElemsInEachPart) { |
| 372 |
get_meta().declare_part_with_topology(elemCountAndPart.second, stk::topology::HEX_8); |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
template <typename T> |
| 377 |
stk::mesh::Field<T> & build_mesh_with_scalar_field_default_debugger(const std::string & fieldName, |
| 378 |
const std::vector<std::pair<unsigned, std::string>> & numElemsInEachPart) |
| 379 |
{ |
| 380 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 381 |
get_meta().enable_field_sync_debugger(); |
| 382 |
stk::mesh::Field<T> & stkField = create_scalar_field<T>(stk::topology::ELEM_RANK, fieldName); |
| 383 |
create_parts(numElemsInEachPart); |
| 384 |
|
| 385 |
unsigned numElems = 0; |
| 386 |
for (const auto & elemCountAndPart : numElemsInEachPart) { |
| 387 |
numElems += elemCountAndPart.first; |
| 388 |
} |
| 389 |
stk::io::fill_mesh("generated:1x1x" + std::to_string(numElems), get_bulk()); |
| 390 |
|
| 391 |
set_initial_part_membership(numElemsInEachPart); |
| 392 |
fill_initial_field<T>(stkField); |
| 393 |
initialize_ngp_field_default_debugger(stkField); |
| 394 |
return stkField; |
| 395 |
} |
| 396 |
|
| 397 |
template <typename T> |
| 398 |
stk::mesh::Field<T> & build_mesh_with_scalar_field(const std::string & fieldName, |
| 399 |
const std::vector<std::pair<unsigned, std::string>> & numElemsInEachPart) |
| 400 |
{ |
| 401 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 402 |
get_meta().enable_field_sync_debugger(); |
| 403 |
stk::mesh::Field<T> & stkField = create_scalar_field<T>(stk::topology::ELEM_RANK, fieldName); |
| 404 |
create_parts(numElemsInEachPart); |
| 405 |
|
| 406 |
unsigned numElems = 0; |
| 407 |
for (const auto & elemCountAndPart : numElemsInEachPart) { |
| 408 |
numElems += elemCountAndPart.first; |
| 409 |
} |
| 410 |
|
| 411 |
stk::io::fill_mesh("generated:1x1x" + std::to_string(numElems), get_bulk()); |
| 412 |
|
| 413 |
set_initial_part_membership(numElemsInEachPart); |
| 414 |
fill_initial_field<T>(stkField); |
| 415 |
initialize_ngp_field(stkField); |
| 416 |
return stkField; |
| 417 |
} |
| 418 |
|
| 419 |
template <typename T> |
| 420 |
stk::mesh::Field<T> & build_mesh_with_vector_field(const std::string & fieldName, |
| 421 |
const std::vector<std::pair<unsigned, std::string>> & numElemsInEachPart) |
| 422 |
{ |
| 423 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 424 |
get_meta().enable_field_sync_debugger(); |
| 425 |
stk::mesh::Field<T> & stkField = create_vector_field<T>(stk::topology::ELEM_RANK, fieldName); |
| 426 |
create_parts(numElemsInEachPart); |
| 427 |
|
| 428 |
unsigned numElems = 0; |
| 429 |
for (const auto & elemCountAndPart : numElemsInEachPart) { |
| 430 |
numElems += elemCountAndPart.first; |
| 431 |
} |
| 432 |
stk::io::fill_mesh("generated:1x1x" + std::to_string(numElems), get_bulk()); |
| 433 |
|
| 434 |
set_initial_part_membership(numElemsInEachPart); |
| 435 |
fill_initial_field<T>(stkField); |
| 436 |
initialize_ngp_field(stkField); |
| 437 |
return stkField; |
| 438 |
} |
| 439 |
|
| 440 |
}; |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_ProperlySyncToDevice_NoWarning) |
| 445 |
{ |
| 446 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 447 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 448 |
|
| 449 |
testing::internal::CaptureStdout(); |
| 450 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 451 |
stkField.modify_on_host(); |
| 452 |
stkField.sync_to_device(); |
| 453 |
|
| 454 |
read_scalar_field_on_device(stkField); |
| 455 |
|
| 456 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 457 |
check_no_warnings(stdoutString); |
| 458 |
} |
| 459 |
|
| 460 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingAllModifySyncCallsToDevice_Warning) |
| 461 |
{ |
| 462 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 463 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 464 |
|
| 465 |
testing::internal::CaptureStdout(); |
| 466 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 467 |
|
| 468 |
read_scalar_field_on_device(stkField); |
| 469 |
|
| 470 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 471 |
check_contains_file_name(stdoutString, "NgpDebugFieldSync_Fixtures.hpp"); |
| 472 |
check_contains_a_line_number(stdoutString); |
| 473 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 474 |
check_no_warnings(stdoutString); |
| 475 |
} |
| 476 |
|
| 477 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingSyncToDevice_Warning) |
| 478 |
{ |
| 479 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 480 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 481 |
|
| 482 |
testing::internal::CaptureStdout(); |
| 483 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 484 |
stkField.modify_on_host(); |
| 485 |
|
| 486 |
read_scalar_field_on_device(stkField); |
| 487 |
|
| 488 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 489 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 490 |
check_no_warnings(stdoutString); |
| 491 |
} |
| 492 |
|
| 493 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingModifyOnHost_Warning) |
| 494 |
{ |
| 495 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 496 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 497 |
|
| 498 |
testing::internal::CaptureStdout(); |
| 499 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 500 |
stkField.sync_to_device(); |
| 501 |
|
| 502 |
read_scalar_field_on_device(stkField); |
| 503 |
|
| 504 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 505 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 506 |
check_no_warnings(stdoutString); |
| 507 |
} |
| 508 |
|
| 509 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_ProperlySyncToDevice_NoWarning) |
| 510 |
{ |
| 511 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 512 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 513 |
|
| 514 |
testing::internal::CaptureStdout(); |
| 515 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 516 |
stkField.modify_on_host(); |
| 517 |
stkField.sync_to_device(); |
| 518 |
|
| 519 |
read_vector_field_on_device(stkField); |
| 520 |
|
| 521 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 522 |
check_no_warnings(stdoutString); |
| 523 |
} |
| 524 |
|
| 525 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_MissingAllModifySyncCallsToDevice_Warning) |
| 526 |
{ |
| 527 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 528 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 529 |
|
| 530 |
testing::internal::CaptureStdout(); |
| 531 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 532 |
|
| 533 |
read_vector_field_on_device(stkField); |
| 534 |
|
| 535 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 536 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[0]=10.000000"); |
| 537 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 538 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[2]=12.000000"); |
| 539 |
check_no_warnings(stdoutString); |
| 540 |
} |
| 541 |
|
| 542 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntityFieldData_ProperlySyncToDevice_NoWarning) |
| 543 |
{ |
| 544 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 545 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 546 |
|
| 547 |
testing::internal::CaptureStdout(); |
| 548 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 549 |
stkField.modify_on_host(); |
| 550 |
stkField.sync_to_device(); |
| 551 |
|
| 552 |
read_field_on_device_using_entity_field_data(stkField); |
| 553 |
|
| 554 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 555 |
check_no_warnings(stdoutString); |
| 556 |
} |
| 557 |
|
| 558 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntityFieldData_MissingAllModifySyncCallsToDevice_Warning) |
| 559 |
{ |
| 560 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 561 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 562 |
|
| 563 |
testing::internal::CaptureStdout(); |
| 564 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 565 |
|
| 566 |
read_field_on_device_using_entity_field_data(stkField); |
| 567 |
|
| 568 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 569 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[0]=10.000000"); |
| 570 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 571 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[2]=12.000000"); |
| 572 |
check_no_warnings(stdoutString); |
| 573 |
} |
| 574 |
|
| 575 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingMeshIndex_ProperlySyncToDevice_NoWarning) |
| 576 |
{ |
| 577 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 578 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 579 |
|
| 580 |
testing::internal::CaptureStdout(); |
| 581 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 582 |
stkField.modify_on_host(); |
| 583 |
stkField.sync_to_device(); |
| 584 |
|
| 585 |
read_field_on_device_using_mesh_index(stkField); |
| 586 |
|
| 587 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 588 |
check_no_warnings(stdoutString); |
| 589 |
} |
| 590 |
|
| 591 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingMeshIndex_MissingAllModifySyncCallsToDevice_Warning) |
| 592 |
{ |
| 593 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 594 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 595 |
|
| 596 |
testing::internal::CaptureStdout(); |
| 597 |
write_vector_field_on_host_using_entity(stkField, 3.14); |
| 598 |
|
| 599 |
read_field_on_device_using_mesh_index(stkField); |
| 600 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 601 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[0]=10.000000"); |
| 602 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 603 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[2]=12.000000"); |
| 604 |
check_no_warnings(stdoutString); |
| 605 |
} |
| 606 |
|
| 607 |
TEST_F(NgpDebugFieldSync, ScalarIntAccessUsingEntity_ProperlySyncToDevice_NoWarning) |
| 608 |
{ |
| 609 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 610 |
stk::mesh::Field<int> & stkField = build_mesh_with_scalar_field<int>("intScalarField", {{2, "Part1"}}); |
| 611 |
|
| 612 |
testing::internal::CaptureStdout(); |
| 613 |
write_scalar_field_on_host_using_entity(stkField, 3); |
| 614 |
stkField.modify_on_host(); |
| 615 |
stkField.sync_to_device(); |
| 616 |
|
| 617 |
read_scalar_field_on_device(stkField); |
| 618 |
|
| 619 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 620 |
check_no_warnings(stdoutString); |
| 621 |
} |
| 622 |
|
| 623 |
TEST_F(NgpDebugFieldSync, ScalarIntAccessUsingEntity_MissingAllModifySyncCallsToDevice_Warning) |
| 624 |
{ |
| 625 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 626 |
stk::mesh::Field<int> & stkField = build_mesh_with_scalar_field<int>("intScalarField", {{2, "Part1"}}); |
| 627 |
|
| 628 |
testing::internal::CaptureStdout(); |
| 629 |
write_scalar_field_on_host_using_entity(stkField, 3); |
| 630 |
|
| 631 |
read_scalar_field_on_device(stkField); |
| 632 |
|
| 633 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 634 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field intScalarField[0]=10.000000"); |
| 635 |
check_no_warnings(stdoutString); |
| 636 |
} |
| 637 |
|
| 638 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingEntity_ProperlySyncToDevice_NoWarning) |
| 639 |
{ |
| 640 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 641 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{2, "Part1"}}); |
| 642 |
|
| 643 |
testing::internal::CaptureStdout(); |
| 644 |
write_vector_field_on_host_using_entity(stkField, 3); |
| 645 |
stkField.modify_on_host(); |
| 646 |
stkField.sync_to_device(); |
| 647 |
|
| 648 |
read_vector_field_on_device(stkField); |
| 649 |
|
| 650 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 651 |
check_no_warnings(stdoutString); |
| 652 |
} |
| 653 |
|
| 654 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingEntity_MissingAllModifySyncCallsToDevice_Warning) |
| 655 |
{ |
| 656 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 657 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{2, "Part1"}}); |
| 658 |
|
| 659 |
testing::internal::CaptureStdout(); |
| 660 |
write_vector_field_on_host_using_entity(stkField, 3); |
| 661 |
|
| 662 |
read_vector_field_on_device(stkField); |
| 663 |
|
| 664 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 665 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field intVectorField[0]=10.000000"); |
| 666 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field intVectorField[1]=11.000000"); |
| 667 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field intVectorField[2]=12.000000"); |
| 668 |
check_no_warnings(stdoutString); |
| 669 |
} |
| 670 |
|
| 671 |
|
| 672 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_ProperlySyncToDevice_NoWarning) |
| 673 |
{ |
| 674 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 675 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 676 |
{1, "Part2"}}); |
| 677 |
|
| 678 |
testing::internal::CaptureStdout(); |
| 679 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 680 |
stkField.modify_on_host(); |
| 681 |
stkField.sync_to_device(); |
| 682 |
|
| 683 |
read_scalar_field_on_device(stkField); |
| 684 |
|
| 685 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 686 |
check_no_warnings(stdoutString); |
| 687 |
} |
| 688 |
|
| 689 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MissingAllModifySyncCallsToDevice_Warning) |
| 690 |
{ |
| 691 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 692 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 693 |
{1, "Part2"}}); |
| 694 |
|
| 695 |
testing::internal::CaptureStdout(); |
| 696 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 697 |
|
| 698 |
read_scalar_field_on_device(stkField); |
| 699 |
|
| 700 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 701 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 702 |
check_no_warnings(stdoutString); |
| 703 |
} |
| 704 |
|
| 705 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucket_ProperlySyncToDevice_NoWarning) |
| 706 |
{ |
| 707 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 708 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleScalarField", {{1, "Part1"}, |
| 709 |
{1, "Part2"}}); |
| 710 |
|
| 711 |
testing::internal::CaptureStdout(); |
| 712 |
write_vector_field_on_host_using_bucket(stkField, 3.14); |
| 713 |
stkField.modify_on_host(); |
| 714 |
stkField.sync_to_device(); |
| 715 |
|
| 716 |
read_vector_field_on_device(stkField); |
| 717 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 718 |
check_no_warnings(stdoutString); |
| 719 |
} |
| 720 |
|
| 721 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucket_MissingAllModifySyncCallsToDevice_Warning) |
| 722 |
{ |
| 723 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 724 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 725 |
{1, "Part2"}}); |
| 726 |
|
| 727 |
testing::internal::CaptureStdout(); |
| 728 |
write_vector_field_on_host_using_bucket(stkField, 3.14); |
| 729 |
|
| 730 |
read_vector_field_on_device(stkField); |
| 731 |
|
| 732 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 733 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 734 |
check_no_warnings(stdoutString); |
| 735 |
} |
| 736 |
|
| 737 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketId_ProperlySyncToDevice_NoWarning) |
| 738 |
{ |
| 739 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 740 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 741 |
{1, "Part2"}}); |
| 742 |
|
| 743 |
testing::internal::CaptureStdout(); |
| 744 |
write_scalar_field_on_host_using_bucket_id(stkField, 3.14); |
| 745 |
stkField.modify_on_host(); |
| 746 |
stkField.sync_to_device(); |
| 747 |
|
| 748 |
read_scalar_field_on_device(stkField); |
| 749 |
|
| 750 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 751 |
check_no_warnings(stdoutString); |
| 752 |
} |
| 753 |
|
| 754 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketId_MissingAllModifySyncCallsToDevice_Warning) |
| 755 |
{ |
| 756 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 757 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 758 |
{1, "Part2"}}); |
| 759 |
|
| 760 |
testing::internal::CaptureStdout(); |
| 761 |
write_scalar_field_on_host_using_bucket_id(stkField, 3.14); |
| 762 |
|
| 763 |
read_scalar_field_on_device(stkField); |
| 764 |
|
| 765 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 766 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 767 |
check_no_warnings(stdoutString); |
| 768 |
} |
| 769 |
|
| 770 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketId_ProperlySyncToDevice_NoWarning) |
| 771 |
{ |
| 772 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 773 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleScalarField", {{1, "Part1"}, |
| 774 |
{1, "Part2"}}); |
| 775 |
|
| 776 |
testing::internal::CaptureStdout(); |
| 777 |
write_vector_field_on_host_using_bucket_id(stkField, 3.14); |
| 778 |
stkField.modify_on_host(); |
| 779 |
stkField.sync_to_device(); |
| 780 |
|
| 781 |
read_vector_field_on_device(stkField); |
| 782 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 783 |
check_no_warnings(stdoutString); |
| 784 |
} |
| 785 |
|
| 786 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketId_MissingAllModifySyncCallsToDevice_Warning) |
| 787 |
{ |
| 788 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 789 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 790 |
{1, "Part2"}}); |
| 791 |
|
| 792 |
testing::internal::CaptureStdout(); |
| 793 |
write_vector_field_on_host_using_bucket_id(stkField, 3.14); |
| 794 |
|
| 795 |
read_vector_field_on_device(stkField); |
| 796 |
|
| 797 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 798 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 799 |
check_no_warnings(stdoutString); |
| 800 |
} |
| 801 |
|
| 802 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingBucket_ProperlySyncToDevice_NoWarning) |
| 803 |
{ |
| 804 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 805 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intScalarField", {{1, "Part1"}, |
| 806 |
{1, "Part2"}}); |
| 807 |
|
| 808 |
testing::internal::CaptureStdout(); |
| 809 |
write_vector_field_on_host_using_bucket(stkField, 3); |
| 810 |
stkField.modify_on_host(); |
| 811 |
stkField.sync_to_device(); |
| 812 |
|
| 813 |
read_vector_field_on_device(stkField); |
| 814 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 815 |
check_no_warnings(stdoutString); |
| 816 |
} |
| 817 |
|
| 818 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingBucket_MissingAllModifySyncCallsToDevice_Warning) |
| 819 |
{ |
| 820 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 821 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{1, "Part1"}, |
| 822 |
{1, "Part2"}}); |
| 823 |
|
| 824 |
testing::internal::CaptureStdout(); |
| 825 |
write_vector_field_on_host_using_bucket(stkField, 3); |
| 826 |
|
| 827 |
read_vector_field_on_device(stkField); |
| 828 |
|
| 829 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 830 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field intVectorField[1]=11.000000"); |
| 831 |
check_no_warnings(stdoutString); |
| 832 |
} |
| 833 |
|
| 834 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketIdAndOrdinal_ProperlySyncToDevice_NoWarning) |
| 835 |
{ |
| 836 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 837 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 838 |
{1, "Part2"}}); |
| 839 |
|
| 840 |
testing::internal::CaptureStdout(); |
| 841 |
write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14); |
| 842 |
stkField.modify_on_host(); |
| 843 |
stkField.sync_to_device(); |
| 844 |
|
| 845 |
read_scalar_field_on_device(stkField); |
| 846 |
|
| 847 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 848 |
check_no_warnings(stdoutString); |
| 849 |
} |
| 850 |
|
| 851 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketIdAndOrdinal_MissingAllModifySyncCallsToDevice_Warning) |
| 852 |
{ |
| 853 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 854 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 855 |
{1, "Part2"}}); |
| 856 |
|
| 857 |
testing::internal::CaptureStdout(); |
| 858 |
write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14); |
| 859 |
|
| 860 |
read_scalar_field_on_device(stkField); |
| 861 |
|
| 862 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 863 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 864 |
check_no_warnings(stdoutString); |
| 865 |
} |
| 866 |
|
| 867 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketIdAndOrdinal_ProperlySyncToDevice_NoWarning) |
| 868 |
{ |
| 869 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 870 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleScalarField", {{1, "Part1"}, |
| 871 |
{1, "Part2"}}); |
| 872 |
|
| 873 |
testing::internal::CaptureStdout(); |
| 874 |
write_vector_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14); |
| 875 |
stkField.modify_on_host(); |
| 876 |
stkField.sync_to_device(); |
| 877 |
|
| 878 |
read_vector_field_on_device(stkField); |
| 879 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 880 |
check_no_warnings(stdoutString); |
| 881 |
} |
| 882 |
|
| 883 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketIdAndOrdinal_MissingAllModifySyncCallsToDevice_Warning) |
| 884 |
{ |
| 885 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 886 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 887 |
{1, "Part2"}}); |
| 888 |
|
| 889 |
testing::internal::CaptureStdout(); |
| 890 |
write_vector_field_on_host_using_bucket_id_and_ordinal(stkField, 3.14); |
| 891 |
|
| 892 |
read_vector_field_on_device(stkField); |
| 893 |
|
| 894 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 895 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 896 |
check_no_warnings(stdoutString); |
| 897 |
} |
| 898 |
|
| 899 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketIdAndOrdinalAndSize_ProperlySyncToDevice_NoWarning) |
| 900 |
{ |
| 901 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 902 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 903 |
{1, "Part2"}}); |
| 904 |
|
| 905 |
testing::internal::CaptureStdout(); |
| 906 |
write_scalar_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14); |
| 907 |
stkField.modify_on_host(); |
| 908 |
stkField.sync_to_device(); |
| 909 |
|
| 910 |
read_scalar_field_on_device(stkField); |
| 911 |
|
| 912 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 913 |
check_no_warnings(stdoutString); |
| 914 |
} |
| 915 |
|
| 916 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucketIdAndOrdinalAndSize_MissingAllModifySyncCallsToDevice_Warning) |
| 917 |
{ |
| 918 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 919 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 920 |
{1, "Part2"}}); |
| 921 |
|
| 922 |
testing::internal::CaptureStdout(); |
| 923 |
write_scalar_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14); |
| 924 |
|
| 925 |
read_scalar_field_on_device(stkField); |
| 926 |
|
| 927 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 928 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 929 |
check_no_warnings(stdoutString); |
| 930 |
} |
| 931 |
|
| 932 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketIdAndOrdinalAndSize_ProperlySyncToDevice_NoWarning) |
| 933 |
{ |
| 934 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 935 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleScalarField", {{1, "Part1"}, |
| 936 |
{1, "Part2"}}); |
| 937 |
|
| 938 |
testing::internal::CaptureStdout(); |
| 939 |
write_vector_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14); |
| 940 |
stkField.modify_on_host(); |
| 941 |
stkField.sync_to_device(); |
| 942 |
|
| 943 |
read_vector_field_on_device(stkField); |
| 944 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 945 |
check_no_warnings(stdoutString); |
| 946 |
} |
| 947 |
|
| 948 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucketIdAndOrdinalAndSize_MissingAllModifySyncCallsToDevice_Warning) |
| 949 |
{ |
| 950 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 951 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 952 |
{1, "Part2"}}); |
| 953 |
|
| 954 |
testing::internal::CaptureStdout(); |
| 955 |
write_vector_field_on_host_using_bucket_id_and_ordinal_and_size(stkField, 3.14); |
| 956 |
|
| 957 |
read_vector_field_on_device(stkField); |
| 958 |
|
| 959 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 960 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 961 |
check_no_warnings(stdoutString); |
| 962 |
} |
| 963 |
|
| 964 |
|
| 965 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_ProperlySyncToHost_NoWarning) |
| 966 |
{ |
| 967 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 968 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 969 |
|
| 970 |
testing::internal::CaptureStdout(); |
| 971 |
write_scalar_field_on_device(stkField, 3.14); |
| 972 |
stkField.modify_on_device(); |
| 973 |
stkField.sync_to_host(); |
| 974 |
|
| 975 |
read_scalar_field_on_host_using_entity(stkField); |
| 976 |
|
| 977 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 978 |
check_no_warnings(stdoutString); |
| 979 |
} |
| 980 |
|
| 981 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingAllModifySyncCallsToHost_Warning) |
| 982 |
{ |
| 983 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 984 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 985 |
|
| 986 |
testing::internal::CaptureStdout(); |
| 987 |
write_scalar_field_on_device(stkField, 3.14); |
| 988 |
|
| 989 |
read_scalar_field_on_host_using_entity(stkField); |
| 990 |
|
| 991 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 992 |
check_contains_file_name(stdoutString, "NgpDebugFieldSync_Fixtures.hpp"); |
| 993 |
check_contains_a_line_number(stdoutString); |
| 994 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 995 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 996 |
check_no_warnings(stdoutString); |
| 997 |
} |
| 998 |
|
| 999 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingSyncToHost_Warning) |
| 1000 |
{ |
| 1001 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1002 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1003 |
|
| 1004 |
testing::internal::CaptureStdout(); |
| 1005 |
write_scalar_field_on_device(stkField, 3.14); |
| 1006 |
stkField.modify_on_device(); |
| 1007 |
|
| 1008 |
read_scalar_field_on_host_using_entity(stkField); |
| 1009 |
|
| 1010 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1011 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1012 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1013 |
check_no_warnings(stdoutString); |
| 1014 |
} |
| 1015 |
|
| 1016 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MissingModifyOnDevice_Warning) |
| 1017 |
{ |
| 1018 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1019 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1020 |
|
| 1021 |
testing::internal::CaptureStdout(); |
| 1022 |
write_scalar_field_on_device(stkField, 3.14); |
| 1023 |
stkField.sync_to_host(); |
| 1024 |
|
| 1025 |
read_scalar_field_on_host_using_entity(stkField); |
| 1026 |
|
| 1027 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1028 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1029 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1030 |
check_no_warnings(stdoutString); |
| 1031 |
} |
| 1032 |
|
| 1033 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_ProperlySyncToHost_NoWarning) |
| 1034 |
{ |
| 1035 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1036 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1037 |
|
| 1038 |
testing::internal::CaptureStdout(); |
| 1039 |
write_vector_field_on_device(stkField, 3.14); |
| 1040 |
stkField.modify_on_device(); |
| 1041 |
stkField.sync_to_host(); |
| 1042 |
|
| 1043 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1044 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1045 |
check_no_warnings(stdoutString); |
| 1046 |
} |
| 1047 |
|
| 1048 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_MissingAllModifySyncCallsToHost_Warning) |
| 1049 |
{ |
| 1050 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1051 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1052 |
|
| 1053 |
testing::internal::CaptureStdout(); |
| 1054 |
write_vector_field_on_device(stkField, 3.14); |
| 1055 |
|
| 1056 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1057 |
|
| 1058 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1059 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[0]=10"); |
| 1060 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=11"); |
| 1061 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[2]=12"); |
| 1062 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[0]=20"); |
| 1063 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=21"); |
| 1064 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[2]=22"); |
| 1065 |
check_no_warnings(stdoutString); |
| 1066 |
} |
| 1067 |
|
| 1068 |
TEST_F(NgpDebugFieldSync, DeviceEntityFieldDataAccess_ProperlySyncToHost_NoWarning) |
| 1069 |
{ |
| 1070 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1071 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1072 |
|
| 1073 |
testing::internal::CaptureStdout(); |
| 1074 |
write_vector_field_on_device_using_entity_field_data(stkField, 3.14); |
| 1075 |
stkField.modify_on_device(); |
| 1076 |
stkField.sync_to_host(); |
| 1077 |
|
| 1078 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1079 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1080 |
check_no_warnings(stdoutString); |
| 1081 |
} |
| 1082 |
|
| 1083 |
TEST_F(NgpDebugFieldSync, DeviceEntityFieldDataAccess_MissingAllModifySyncCallsToHost_Warning) |
| 1084 |
{ |
| 1085 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1086 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1087 |
|
| 1088 |
testing::internal::CaptureStdout(); |
| 1089 |
write_vector_field_on_device_using_entity_field_data(stkField, 3.14); |
| 1090 |
|
| 1091 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1092 |
|
| 1093 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1094 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=11"); |
| 1095 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=21"); |
| 1096 |
check_no_warnings(stdoutString); |
| 1097 |
} |
| 1098 |
|
| 1099 |
TEST_F(NgpDebugFieldSync, DeviceMeshIndexAccess_ProperlySyncToHost_NoWarning) |
| 1100 |
{ |
| 1101 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1102 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1103 |
|
| 1104 |
testing::internal::CaptureStdout(); |
| 1105 |
write_vector_field_on_device_using_mesh_index(stkField, 3.14); |
| 1106 |
stkField.modify_on_device(); |
| 1107 |
stkField.sync_to_host(); |
| 1108 |
|
| 1109 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1110 |
|
| 1111 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1112 |
check_no_warnings(stdoutString); |
| 1113 |
} |
| 1114 |
|
| 1115 |
TEST_F(NgpDebugFieldSync, DeviceMeshIndexAccess_MissingAllModifySyncCallsToHost_Warning) |
| 1116 |
{ |
| 1117 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1118 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1119 |
|
| 1120 |
testing::internal::CaptureStdout(); |
| 1121 |
write_vector_field_on_device_using_mesh_index(stkField, 3.14); |
| 1122 |
|
| 1123 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1124 |
|
| 1125 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1126 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=11"); |
| 1127 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=21"); |
| 1128 |
check_no_warnings(stdoutString); |
| 1129 |
} |
| 1130 |
|
| 1131 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingEntity_ProperlySyncToHost_NoWarning) |
| 1132 |
{ |
| 1133 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1134 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{2, "Part1"}}); |
| 1135 |
|
| 1136 |
testing::internal::CaptureStdout(); |
| 1137 |
write_vector_field_on_device(stkField, 3); |
| 1138 |
stkField.modify_on_device(); |
| 1139 |
stkField.sync_to_host(); |
| 1140 |
|
| 1141 |
read_vector_field_on_host_using_entity<double>(stkField); |
| 1142 |
|
| 1143 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1144 |
check_no_warnings(stdoutString); |
| 1145 |
} |
| 1146 |
|
| 1147 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingEntity_MissingAllModifySyncCallsToHost_Warning) |
| 1148 |
{ |
| 1149 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1150 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{2, "Part1"}}); |
| 1151 |
|
| 1152 |
testing::internal::CaptureStdout(); |
| 1153 |
write_vector_field_on_device(stkField, 3); |
| 1154 |
|
| 1155 |
read_vector_field_on_host_using_entity<int>(stkField); |
| 1156 |
|
| 1157 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1158 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[0]=10"); |
| 1159 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[1]=11"); |
| 1160 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[2]=12"); |
| 1161 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[0]=20"); |
| 1162 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[1]=21"); |
| 1163 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[2]=22"); |
| 1164 |
check_no_warnings(stdoutString); |
| 1165 |
} |
| 1166 |
|
| 1167 |
|
| 1168 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_ProperlySyncToHost_NoWarning) |
| 1169 |
{ |
| 1170 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1171 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1172 |
{1, "Part2"}}); |
| 1173 |
|
| 1174 |
testing::internal::CaptureStdout(); |
| 1175 |
write_scalar_field_on_device(stkField, 3.14); |
| 1176 |
stkField.modify_on_device(); |
| 1177 |
stkField.sync_to_host(); |
| 1178 |
|
| 1179 |
read_scalar_field_on_host_using_bucket(stkField); |
| 1180 |
|
| 1181 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1182 |
check_no_warnings(stdoutString); |
| 1183 |
} |
| 1184 |
|
| 1185 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1186 |
{ |
| 1187 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1188 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1189 |
{1, "Part2"}}); |
| 1190 |
|
| 1191 |
testing::internal::CaptureStdout(); |
| 1192 |
write_scalar_field_on_device(stkField, 3.14); |
| 1193 |
|
| 1194 |
read_scalar_field_on_host_using_bucket(stkField); |
| 1195 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1196 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1197 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1198 |
check_no_warnings(stdoutString); |
| 1199 |
} |
| 1200 |
|
| 1201 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucket_ProperlySyncToHost_NoWarning) |
| 1202 |
{ |
| 1203 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1204 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 1205 |
{1, "Part2"}}); |
| 1206 |
|
| 1207 |
testing::internal::CaptureStdout(); |
| 1208 |
write_vector_field_on_device(stkField, 3.14); |
| 1209 |
stkField.modify_on_device(); |
| 1210 |
stkField.sync_to_host(); |
| 1211 |
|
| 1212 |
read_vector_field_on_host_using_bucket(stkField); |
| 1213 |
|
| 1214 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1215 |
check_no_warnings(stdoutString); |
| 1216 |
} |
| 1217 |
|
| 1218 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1219 |
{ |
| 1220 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1221 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{1, "Part1"}, |
| 1222 |
{1, "Part2"}}); |
| 1223 |
|
| 1224 |
testing::internal::CaptureStdout(); |
| 1225 |
write_vector_field_on_device(stkField, 3.14); |
| 1226 |
|
| 1227 |
read_vector_field_on_host_using_bucket(stkField); |
| 1228 |
|
| 1229 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1230 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[0]=10"); |
| 1231 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=11"); |
| 1232 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[2]=12"); |
| 1233 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[0]=20"); |
| 1234 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[1]=21"); |
| 1235 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleVectorField[2]=22"); |
| 1236 |
check_no_warnings(stdoutString); |
| 1237 |
} |
| 1238 |
|
| 1239 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingBucket_ProperlySyncToHost_NoWarning) |
| 1240 |
{ |
| 1241 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1242 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{1, "Part1"}, |
| 1243 |
{1, "Part2"}}); |
| 1244 |
|
| 1245 |
testing::internal::CaptureStdout(); |
| 1246 |
write_vector_field_on_device(stkField, 3); |
| 1247 |
stkField.modify_on_device(); |
| 1248 |
stkField.sync_to_host(); |
| 1249 |
|
| 1250 |
read_vector_field_on_host_using_bucket(stkField); |
| 1251 |
|
| 1252 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1253 |
check_no_warnings(stdoutString); |
| 1254 |
} |
| 1255 |
|
| 1256 |
TEST_F(NgpDebugFieldSync, VectorIntAccessUsingBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1257 |
{ |
| 1258 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1259 |
stk::mesh::Field<int> & stkField = build_mesh_with_vector_field<int>("intVectorField", {{1, "Part1"}, |
| 1260 |
{1, "Part2"}}); |
| 1261 |
|
| 1262 |
testing::internal::CaptureStdout(); |
| 1263 |
write_vector_field_on_device(stkField, 3); |
| 1264 |
|
| 1265 |
read_vector_field_on_host_using_bucket(stkField); |
| 1266 |
|
| 1267 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1268 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[0]=10"); |
| 1269 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[1]=11"); |
| 1270 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[2]=12"); |
| 1271 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[0]=20"); |
| 1272 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[1]=21"); |
| 1273 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field intVectorField[2]=22"); |
| 1274 |
check_no_warnings(stdoutString); |
| 1275 |
} |
| 1276 |
|
| 1277 |
|
| 1278 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_ProperlyMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning) |
| 1279 |
{ |
| 1280 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1281 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1282 |
|
| 1283 |
testing::internal::CaptureStdout(); |
| 1284 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1285 |
stkField.modify_on_host(); |
| 1286 |
stkField.clear_sync_state(); |
| 1287 |
|
| 1288 |
read_scalar_field_on_device(stkField); |
| 1289 |
|
| 1290 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1291 |
check_no_warnings(stdoutString); |
| 1292 |
} |
| 1293 |
|
| 1294 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_MissingMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning) |
| 1295 |
{ |
| 1296 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1297 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1298 |
|
| 1299 |
testing::internal::CaptureStdout(); |
| 1300 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1301 |
stkField.clear_sync_state(); |
| 1302 |
|
| 1303 |
read_scalar_field_on_device(stkField); |
| 1304 |
|
| 1305 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1306 |
check_no_warnings(stdoutString); |
| 1307 |
} |
| 1308 |
|
| 1309 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_ProperlyMarkAsModified_ClearHostSyncState_AccessOnDevice_NoWarning) |
| 1310 |
{ |
| 1311 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1312 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1313 |
|
| 1314 |
testing::internal::CaptureStdout(); |
| 1315 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1316 |
stkField.modify_on_host(); |
| 1317 |
stkField.clear_host_sync_state(); |
| 1318 |
|
| 1319 |
read_scalar_field_on_device(stkField); |
| 1320 |
|
| 1321 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1322 |
check_no_warnings(stdoutString); |
| 1323 |
} |
| 1324 |
|
| 1325 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_MissingMarkAsModified_ClearHostSyncState_AccessOnDevice_NoWarning) |
| 1326 |
{ |
| 1327 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1328 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1329 |
|
| 1330 |
testing::internal::CaptureStdout(); |
| 1331 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1332 |
stkField.clear_host_sync_state(); |
| 1333 |
|
| 1334 |
read_scalar_field_on_device(stkField); |
| 1335 |
|
| 1336 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1337 |
check_no_warnings(stdoutString); |
| 1338 |
} |
| 1339 |
|
| 1340 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_ProperlySyncToDevice_ClearDeviceSyncState_AccessOnDevice_NoWarning) |
| 1341 |
{ |
| 1342 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1343 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1344 |
|
| 1345 |
testing::internal::CaptureStdout(); |
| 1346 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1347 |
stkField.modify_on_host(); |
| 1348 |
stkField.sync_to_device(); |
| 1349 |
stkField.clear_device_sync_state(); |
| 1350 |
|
| 1351 |
read_scalar_field_on_device(stkField); |
| 1352 |
|
| 1353 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1354 |
check_no_warnings(stdoutString); |
| 1355 |
} |
| 1356 |
|
| 1357 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_ProperlyMarkAsModified_ClearDeviceSyncState_AccessOnDevice_Warning) |
| 1358 |
{ |
| 1359 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1360 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1361 |
|
| 1362 |
testing::internal::CaptureStdout(); |
| 1363 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1364 |
stkField.modify_on_host(); |
| 1365 |
stkField.clear_device_sync_state(); |
| 1366 |
|
| 1367 |
read_scalar_field_on_device(stkField); |
| 1368 |
|
| 1369 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1370 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1371 |
check_no_warnings(stdoutString); |
| 1372 |
} |
| 1373 |
|
| 1374 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnHost_MissingMarkAsModified_ClearDeviceSyncState_AccessOnDevice_Warning) |
| 1375 |
{ |
| 1376 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1377 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1378 |
|
| 1379 |
testing::internal::CaptureStdout(); |
| 1380 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1381 |
stkField.clear_device_sync_state(); |
| 1382 |
|
| 1383 |
read_scalar_field_on_device(stkField); |
| 1384 |
|
| 1385 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1386 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1387 |
check_no_warnings(stdoutString); |
| 1388 |
} |
| 1389 |
|
| 1390 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_ProperlyMarkAsModified_ClearSyncState_AccessOnHost_NoWarning) |
| 1391 |
{ |
| 1392 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1393 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1394 |
|
| 1395 |
testing::internal::CaptureStdout(); |
| 1396 |
write_scalar_field_on_device(stkField, 3.14); |
| 1397 |
stkField.modify_on_device(); |
| 1398 |
stkField.clear_sync_state(); |
| 1399 |
|
| 1400 |
read_scalar_field_on_host_using_entity(stkField); |
| 1401 |
|
| 1402 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1403 |
check_no_warnings(stdoutString); |
| 1404 |
} |
| 1405 |
|
| 1406 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_MissingMarkAsModified_ClearSyncState_AccessOnHost_NoWarning) |
| 1407 |
{ |
| 1408 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1409 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1410 |
|
| 1411 |
testing::internal::CaptureStdout(); |
| 1412 |
write_scalar_field_on_device(stkField, 3.14); |
| 1413 |
stkField.clear_sync_state(); |
| 1414 |
|
| 1415 |
read_scalar_field_on_host_using_entity(stkField); |
| 1416 |
|
| 1417 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1418 |
check_no_warnings(stdoutString); |
| 1419 |
} |
| 1420 |
|
| 1421 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_ProperlySyncToHost_ClearHostSyncState_AccessOnHost_NoWarning) |
| 1422 |
{ |
| 1423 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1424 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1425 |
|
| 1426 |
testing::internal::CaptureStdout(); |
| 1427 |
write_scalar_field_on_device(stkField, 3.14); |
| 1428 |
stkField.modify_on_device(); |
| 1429 |
stkField.sync_to_host(); |
| 1430 |
stkField.clear_host_sync_state(); |
| 1431 |
|
| 1432 |
read_scalar_field_on_host_using_entity(stkField); |
| 1433 |
|
| 1434 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1435 |
check_no_warnings(stdoutString); |
| 1436 |
} |
| 1437 |
|
| 1438 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_ProperlyMarkAsModified_ClearHostSyncState_AccessOnHost_Warning) |
| 1439 |
{ |
| 1440 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1441 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1442 |
|
| 1443 |
testing::internal::CaptureStdout(); |
| 1444 |
write_scalar_field_on_device(stkField, 3.14); |
| 1445 |
stkField.modify_on_device(); |
| 1446 |
stkField.clear_host_sync_state(); |
| 1447 |
|
| 1448 |
read_scalar_field_on_host_using_entity(stkField); |
| 1449 |
|
| 1450 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1451 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1452 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1453 |
check_no_warnings(stdoutString); |
| 1454 |
} |
| 1455 |
|
| 1456 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_MissingMarkAsModified_ClearHostSyncState_AccessOnHost_Warning) |
| 1457 |
{ |
| 1458 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1459 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1460 |
|
| 1461 |
testing::internal::CaptureStdout(); |
| 1462 |
write_scalar_field_on_device(stkField, 3.14); |
| 1463 |
stkField.clear_host_sync_state(); |
| 1464 |
|
| 1465 |
read_scalar_field_on_host_using_entity(stkField); |
| 1466 |
|
| 1467 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1468 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1469 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1470 |
check_no_warnings(stdoutString); |
| 1471 |
} |
| 1472 |
|
| 1473 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_ProperlyMarkAsModified_ClearDeviceSyncState_AccessOnHost_NoWarning) |
| 1474 |
{ |
| 1475 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1476 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1477 |
|
| 1478 |
testing::internal::CaptureStdout(); |
| 1479 |
write_scalar_field_on_device(stkField, 3.14); |
| 1480 |
stkField.modify_on_device(); |
| 1481 |
stkField.clear_device_sync_state(); |
| 1482 |
|
| 1483 |
read_scalar_field_on_host_using_entity(stkField); |
| 1484 |
|
| 1485 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1486 |
check_no_warnings(stdoutString); |
| 1487 |
} |
| 1488 |
|
| 1489 |
TEST_F(NgpDebugFieldSync, ScalarWriteOnDevice_MissingMarkAsModified_ClearDeviceSyncState_AccessOnHost_NoWarning) |
| 1490 |
{ |
| 1491 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1492 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1493 |
|
| 1494 |
testing::internal::CaptureStdout(); |
| 1495 |
write_scalar_field_on_device(stkField, 3.14); |
| 1496 |
stkField.clear_device_sync_state(); |
| 1497 |
|
| 1498 |
read_scalar_field_on_host_using_entity(stkField); |
| 1499 |
|
| 1500 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1501 |
check_no_warnings(stdoutString); |
| 1502 |
} |
| 1503 |
|
| 1504 |
|
| 1505 |
TEST_F(NgpDebugFieldSync, ScalarDeviceSetAll_AccessOnHost_Warning) |
| 1506 |
{ |
| 1507 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1508 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1509 |
|
| 1510 |
testing::internal::CaptureStdout(); |
| 1511 |
device_field_set_all(stkField, 2.18); |
| 1512 |
|
| 1513 |
read_scalar_field_on_host_using_entity(stkField); |
| 1514 |
|
| 1515 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1516 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1517 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1518 |
check_no_warnings(stdoutString); |
| 1519 |
} |
| 1520 |
|
| 1521 |
TEST_F(NgpDebugFieldSync, ScalarDeviceSetAll_AccessOnDevice_NoWarning) |
| 1522 |
{ |
| 1523 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1524 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1525 |
|
| 1526 |
testing::internal::CaptureStdout(); |
| 1527 |
device_field_set_all(stkField, 2.18); |
| 1528 |
|
| 1529 |
read_scalar_field_on_device(stkField); |
| 1530 |
|
| 1531 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1532 |
check_no_warnings(stdoutString); |
| 1533 |
} |
| 1534 |
|
| 1535 |
TEST_F(NgpDebugFieldSync, ScalarDeviceSetAll_MissingAllModifySyncCallsToDevice_Warning) |
| 1536 |
{ |
| 1537 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1538 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1539 |
|
| 1540 |
testing::internal::CaptureStdout(); |
| 1541 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1542 |
|
| 1543 |
device_field_set_all(stkField, 2.18); |
| 1544 |
|
| 1545 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1546 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]"); |
| 1547 |
check_no_warnings(stdoutString); |
| 1548 |
} |
| 1549 |
|
| 1550 |
TEST_F(NgpDebugFieldSync, ScalarDeviceSetAll_MissingAllModifySyncCallsToHost_AccessOnHost_Warning) |
| 1551 |
{ |
| 1552 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1553 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1554 |
|
| 1555 |
testing::internal::CaptureStdout(); |
| 1556 |
write_scalar_field_on_device(stkField, 3.14); |
| 1557 |
|
| 1558 |
device_field_set_all(stkField, 2.18); |
| 1559 |
|
| 1560 |
read_scalar_field_on_host_using_entity(stkField); |
| 1561 |
|
| 1562 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1563 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1564 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1565 |
check_no_warnings(stdoutString); |
| 1566 |
} |
| 1567 |
|
| 1568 |
TEST_F(NgpDebugFieldSync, ScalarDeviceSetAll_MissingAllModifySyncCallsToHost_AccessOnDevice_NoWarning) |
| 1569 |
{ |
| 1570 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1571 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1572 |
|
| 1573 |
testing::internal::CaptureStdout(); |
| 1574 |
write_scalar_field_on_device(stkField, 3.14); |
| 1575 |
|
| 1576 |
device_field_set_all(stkField, 2.18); |
| 1577 |
|
| 1578 |
read_scalar_field_on_device(stkField); |
| 1579 |
|
| 1580 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1581 |
check_no_warnings(stdoutString); |
| 1582 |
} |
| 1583 |
|
| 1584 |
|
| 1585 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_ProperlySyncToDevice_NoWarning) |
| 1586 |
{ |
| 1587 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1588 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1589 |
|
| 1590 |
testing::internal::CaptureStdout(); |
| 1591 |
|
| 1592 |
const size_t numTimeSteps = 2; |
| 1593 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1594 |
write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1595 |
stkField.modify_on_host(); |
| 1596 |
stkField.sync_to_device(); |
| 1597 |
read_scalar_field_on_device(stkField); |
| 1598 |
} |
| 1599 |
|
| 1600 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1601 |
check_no_warnings(stdoutString); |
| 1602 |
} |
| 1603 |
|
| 1604 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_MissingAllModifySyncCallsToDevice_Warning) |
| 1605 |
{ |
| 1606 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1607 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1608 |
|
| 1609 |
testing::internal::CaptureStdout(); |
| 1610 |
|
| 1611 |
const size_t numTimeSteps = 2; |
| 1612 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1613 |
write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1614 |
read_scalar_field_on_device(stkField); |
| 1615 |
} |
| 1616 |
|
| 1617 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1618 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10"); |
| 1619 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20"); |
| 1620 |
check_no_warnings(stdoutString); |
| 1621 |
} |
| 1622 |
|
| 1623 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_ProperlyMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning) |
| 1624 |
{ |
| 1625 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1626 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1627 |
|
| 1628 |
testing::internal::CaptureStdout(); |
| 1629 |
|
| 1630 |
const size_t numTimeSteps = 2; |
| 1631 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1632 |
write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1633 |
stkField.modify_on_host(); |
| 1634 |
stkField.clear_sync_state(); |
| 1635 |
read_scalar_field_on_device(stkField); |
| 1636 |
} |
| 1637 |
|
| 1638 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1639 |
check_no_warnings(stdoutString); |
| 1640 |
} |
| 1641 |
|
| 1642 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_MissingMarkAsModified_ClearSyncState_AccessOnDevice_NoWarning) |
| 1643 |
{ |
| 1644 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1645 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1646 |
|
| 1647 |
testing::internal::CaptureStdout(); |
| 1648 |
|
| 1649 |
const size_t numTimeSteps = 2; |
| 1650 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1651 |
write_scalar_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1652 |
stkField.clear_sync_state(); |
| 1653 |
read_scalar_field_on_device(stkField); |
| 1654 |
} |
| 1655 |
|
| 1656 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1657 |
check_no_warnings(stdoutString); |
| 1658 |
} |
| 1659 |
|
| 1660 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleAccesses_ProperlySyncToDevice_NoWarning) |
| 1661 |
{ |
| 1662 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1663 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1664 |
|
| 1665 |
testing::internal::CaptureStdout(); |
| 1666 |
|
| 1667 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1668 |
stkField.modify_on_host(); |
| 1669 |
stkField.sync_to_device(); |
| 1670 |
|
| 1671 |
read_scalar_field_on_device(stkField); |
| 1672 |
read_scalar_field_on_device(stkField); |
| 1673 |
|
| 1674 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1675 |
check_no_warnings(stdoutString); |
| 1676 |
} |
| 1677 |
|
| 1678 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleStaleAccesses_MissingAllModifySyncCallsToDevice_Warning) |
| 1679 |
{ |
| 1680 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1681 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1682 |
|
| 1683 |
testing::internal::CaptureStdout(); |
| 1684 |
|
| 1685 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1686 |
|
| 1687 |
read_scalar_field_on_device(stkField); |
| 1688 |
read_scalar_field_on_device(stkField); |
| 1689 |
|
| 1690 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1691 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1692 |
check_no_warnings(stdoutString); |
| 1693 |
} |
| 1694 |
|
| 1695 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleWrites_ProperlySyncToDevice_NoWarning) |
| 1696 |
{ |
| 1697 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1698 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1699 |
|
| 1700 |
testing::internal::CaptureStdout(); |
| 1701 |
|
| 1702 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1703 |
write_scalar_field_on_host_using_entity(stkField, 2.18); |
| 1704 |
stkField.modify_on_host(); |
| 1705 |
stkField.sync_to_device(); |
| 1706 |
|
| 1707 |
read_scalar_field_on_device(stkField); |
| 1708 |
|
| 1709 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1710 |
check_no_warnings(stdoutString); |
| 1711 |
} |
| 1712 |
|
| 1713 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleWrites_MissingAllModifySyncCallsToDevice_Warning) |
| 1714 |
{ |
| 1715 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1716 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1717 |
|
| 1718 |
testing::internal::CaptureStdout(); |
| 1719 |
|
| 1720 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 1721 |
write_scalar_field_on_host_using_entity(stkField, 2.18); |
| 1722 |
|
| 1723 |
read_scalar_field_on_device(stkField); |
| 1724 |
|
| 1725 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1726 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1727 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20.000000"); |
| 1728 |
check_no_warnings(stdoutString); |
| 1729 |
} |
| 1730 |
|
| 1731 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_MultipleTimestep_ProperlySyncToDevice_NoWarning) |
| 1732 |
{ |
| 1733 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1734 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1735 |
|
| 1736 |
testing::internal::CaptureStdout(); |
| 1737 |
|
| 1738 |
const size_t numTimeSteps = 2; |
| 1739 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1740 |
write_vector_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1741 |
stkField.modify_on_host(); |
| 1742 |
stkField.sync_to_device(); |
| 1743 |
read_vector_field_on_device(stkField); |
| 1744 |
} |
| 1745 |
|
| 1746 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1747 |
check_no_warnings(stdoutString); |
| 1748 |
} |
| 1749 |
|
| 1750 |
TEST_F(NgpDebugFieldSync, VectorAccessUsingEntity_MultipleTimestep_MissingAllModifySyncCallsToDevice_Warning) |
| 1751 |
{ |
| 1752 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1753 |
stk::mesh::Field<double> & stkField = build_mesh_with_vector_field<double>("doubleVectorField", {{2, "Part1"}}); |
| 1754 |
|
| 1755 |
testing::internal::CaptureStdout(); |
| 1756 |
|
| 1757 |
const size_t numTimeSteps = 2; |
| 1758 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1759 |
write_vector_field_on_host_using_entity(stkField, 3.14+timeStep); |
| 1760 |
read_vector_field_on_device(stkField); |
| 1761 |
} |
| 1762 |
|
| 1763 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1764 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleVectorField[0]=10.000000"); |
| 1765 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=11.000000"); |
| 1766 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleVectorField[2]=12.000000"); |
| 1767 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[0]=20.000000"); |
| 1768 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[1]=21.000000"); |
| 1769 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleVectorField[2]=22.000000"); |
| 1770 |
check_no_warnings(stdoutString); |
| 1771 |
} |
| 1772 |
|
| 1773 |
|
| 1774 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleTimestep_ProperlySyncToDevice_NoWarning) |
| 1775 |
{ |
| 1776 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1777 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1778 |
{1, "Part2"}}); |
| 1779 |
|
| 1780 |
testing::internal::CaptureStdout(); |
| 1781 |
|
| 1782 |
const size_t numTimeSteps = 2; |
| 1783 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1784 |
write_scalar_field_on_host_using_bucket(stkField, 3.14+timeStep); |
| 1785 |
stkField.modify_on_host(); |
| 1786 |
stkField.sync_to_device(); |
| 1787 |
read_scalar_field_on_device(stkField); |
| 1788 |
} |
| 1789 |
|
| 1790 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1791 |
check_no_warnings(stdoutString); |
| 1792 |
} |
| 1793 |
|
| 1794 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleTimestep_MissingAllModifySyncCallsToDevice_Warning) |
| 1795 |
{ |
| 1796 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1797 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1798 |
{1, "Part2"}}); |
| 1799 |
|
| 1800 |
testing::internal::CaptureStdout(); |
| 1801 |
|
| 1802 |
const size_t numTimeSteps = 2; |
| 1803 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1804 |
write_scalar_field_on_host_using_bucket(stkField, 3.14+timeStep); |
| 1805 |
read_scalar_field_on_device(stkField); |
| 1806 |
} |
| 1807 |
|
| 1808 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1809 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1810 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20.000000"); |
| 1811 |
check_no_warnings(stdoutString); |
| 1812 |
} |
| 1813 |
|
| 1814 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleAccesses_ProperlySyncToDevice_NoWarning) |
| 1815 |
{ |
| 1816 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1817 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1818 |
{1, "Part2"}}); |
| 1819 |
|
| 1820 |
testing::internal::CaptureStdout(); |
| 1821 |
|
| 1822 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 1823 |
stkField.modify_on_host(); |
| 1824 |
stkField.sync_to_device(); |
| 1825 |
|
| 1826 |
read_scalar_field_on_device(stkField); |
| 1827 |
read_scalar_field_on_device(stkField); |
| 1828 |
|
| 1829 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1830 |
check_no_warnings(stdoutString); |
| 1831 |
} |
| 1832 |
|
| 1833 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleStaleAccesses_MissingAllModifySyncCallsToDevice_Warning) |
| 1834 |
{ |
| 1835 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1836 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1837 |
{1, "Part2"}}); |
| 1838 |
|
| 1839 |
testing::internal::CaptureStdout(); |
| 1840 |
|
| 1841 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 1842 |
|
| 1843 |
read_scalar_field_on_device(stkField); |
| 1844 |
read_scalar_field_on_device(stkField); |
| 1845 |
|
| 1846 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1847 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1848 |
check_no_warnings(stdoutString); |
| 1849 |
} |
| 1850 |
|
| 1851 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleWrites_ProperlySyncToDevice_NoWarning) |
| 1852 |
{ |
| 1853 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1854 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1855 |
{1, "Part2"}}); |
| 1856 |
|
| 1857 |
testing::internal::CaptureStdout(); |
| 1858 |
|
| 1859 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 1860 |
write_scalar_field_on_host_using_bucket(stkField, 2.18); |
| 1861 |
stkField.modify_on_host(); |
| 1862 |
stkField.sync_to_device(); |
| 1863 |
|
| 1864 |
read_scalar_field_on_device(stkField); |
| 1865 |
|
| 1866 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1867 |
check_no_warnings(stdoutString); |
| 1868 |
} |
| 1869 |
|
| 1870 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleWrites_MissingAllModifySyncCallsToDevice_Warning) |
| 1871 |
{ |
| 1872 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1873 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 1874 |
{1, "Part2"}}); |
| 1875 |
|
| 1876 |
testing::internal::CaptureStdout(); |
| 1877 |
|
| 1878 |
write_scalar_field_on_host_using_bucket(stkField, 3.14); |
| 1879 |
write_scalar_field_on_host_using_bucket(stkField, 2.18); |
| 1880 |
|
| 1881 |
read_scalar_field_on_device(stkField); |
| 1882 |
|
| 1883 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1884 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=10.000000"); |
| 1885 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Device for Field doubleScalarField[0]=20.000000"); |
| 1886 |
check_no_warnings(stdoutString); |
| 1887 |
} |
| 1888 |
|
| 1889 |
|
| 1890 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_ProperlySyncToHost_NoWarning) |
| 1891 |
{ |
| 1892 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1893 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1894 |
|
| 1895 |
testing::internal::CaptureStdout(); |
| 1896 |
|
| 1897 |
const size_t numTimeSteps = 2; |
| 1898 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1899 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 1900 |
stkField.modify_on_device(); |
| 1901 |
stkField.sync_to_host(); |
| 1902 |
read_scalar_field_on_host_using_entity(stkField); |
| 1903 |
} |
| 1904 |
|
| 1905 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1906 |
check_no_warnings(stdoutString); |
| 1907 |
} |
| 1908 |
|
| 1909 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_MissingAllModifySyncCallsToHost_Warning) |
| 1910 |
{ |
| 1911 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1912 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1913 |
|
| 1914 |
testing::internal::CaptureStdout(); |
| 1915 |
|
| 1916 |
const size_t numTimeSteps = 2; |
| 1917 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1918 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 1919 |
read_scalar_field_on_host_using_entity(stkField); |
| 1920 |
} |
| 1921 |
|
| 1922 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1923 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1924 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1925 |
check_no_warnings(stdoutString); |
| 1926 |
} |
| 1927 |
|
| 1928 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_ProperlyMarkAsModified_ClearSyncState_AccessOnHost_NoWarning) |
| 1929 |
{ |
| 1930 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1931 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1932 |
|
| 1933 |
testing::internal::CaptureStdout(); |
| 1934 |
|
| 1935 |
const size_t numTimeSteps = 2; |
| 1936 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1937 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 1938 |
stkField.modify_on_device(); |
| 1939 |
stkField.clear_sync_state(); |
| 1940 |
read_scalar_field_on_host_using_entity(stkField); |
| 1941 |
} |
| 1942 |
|
| 1943 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1944 |
check_no_warnings(stdoutString); |
| 1945 |
} |
| 1946 |
|
| 1947 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleTimestep_MissingMarkAsModified_ClearSyncState_AccessOnHost_NoWarning) |
| 1948 |
{ |
| 1949 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1950 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1951 |
|
| 1952 |
testing::internal::CaptureStdout(); |
| 1953 |
|
| 1954 |
const size_t numTimeSteps = 2; |
| 1955 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 1956 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 1957 |
stkField.clear_sync_state(); |
| 1958 |
read_scalar_field_on_host_using_entity(stkField); |
| 1959 |
} |
| 1960 |
|
| 1961 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1962 |
check_no_warnings(stdoutString); |
| 1963 |
} |
| 1964 |
|
| 1965 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleAccesses_ProperlySyncToHost_NoWarning) |
| 1966 |
{ |
| 1967 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1968 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1969 |
|
| 1970 |
testing::internal::CaptureStdout(); |
| 1971 |
|
| 1972 |
write_scalar_field_on_device(stkField, 3.14); |
| 1973 |
stkField.modify_on_device(); |
| 1974 |
stkField.sync_to_host(); |
| 1975 |
|
| 1976 |
read_scalar_field_on_host_using_entity(stkField); |
| 1977 |
read_scalar_field_on_host_using_entity(stkField); |
| 1978 |
|
| 1979 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1980 |
check_no_warnings(stdoutString); |
| 1981 |
} |
| 1982 |
|
| 1983 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleStaleAccesses_MissingAllModifySyncCallsToHost_Warning) |
| 1984 |
{ |
| 1985 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1986 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 1987 |
|
| 1988 |
testing::internal::CaptureStdout(); |
| 1989 |
|
| 1990 |
write_scalar_field_on_device(stkField, 3.14); |
| 1991 |
|
| 1992 |
read_scalar_field_on_host_using_entity(stkField); |
| 1993 |
read_scalar_field_on_host_using_entity(stkField); |
| 1994 |
|
| 1995 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1996 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 1997 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 1998 |
check_no_warnings(stdoutString); |
| 1999 |
} |
| 2000 |
|
| 2001 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleWrites_ProperlySyncToHost_NoWarning) |
| 2002 |
{ |
| 2003 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2004 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 2005 |
|
| 2006 |
testing::internal::CaptureStdout(); |
| 2007 |
|
| 2008 |
write_scalar_field_on_device(stkField, 3.14); |
| 2009 |
write_scalar_field_on_device(stkField, 2.18); |
| 2010 |
stkField.modify_on_device(); |
| 2011 |
stkField.sync_to_host(); |
| 2012 |
|
| 2013 |
read_scalar_field_on_host_using_entity(stkField); |
| 2014 |
|
| 2015 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2016 |
check_no_warnings(stdoutString); |
| 2017 |
} |
| 2018 |
|
| 2019 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingEntity_MultipleWrites_MissingAllModifySyncCallsToHost_Warning) |
| 2020 |
{ |
| 2021 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2022 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 2023 |
|
| 2024 |
testing::internal::CaptureStdout(); |
| 2025 |
|
| 2026 |
write_scalar_field_on_device(stkField, 3.14); |
| 2027 |
write_scalar_field_on_device(stkField, 2.18); |
| 2028 |
|
| 2029 |
read_scalar_field_on_host_using_entity(stkField); |
| 2030 |
|
| 2031 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2032 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 2033 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 2034 |
check_no_warnings(stdoutString); |
| 2035 |
} |
| 2036 |
|
| 2037 |
|
| 2038 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleTimestep_ProperlySyncToHost_NoWarning) |
| 2039 |
{ |
| 2040 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2041 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2042 |
{1, "Part2"}}); |
| 2043 |
|
| 2044 |
testing::internal::CaptureStdout(); |
| 2045 |
|
| 2046 |
const size_t numTimeSteps = 2; |
| 2047 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 2048 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 2049 |
stkField.modify_on_device(); |
| 2050 |
stkField.sync_to_host(); |
| 2051 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2052 |
} |
| 2053 |
|
| 2054 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2055 |
check_no_warnings(stdoutString); |
| 2056 |
} |
| 2057 |
|
| 2058 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleTimestep_MissingAllModifySyncCallsToHost_Warning) |
| 2059 |
{ |
| 2060 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2061 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2062 |
{1, "Part2"}}); |
| 2063 |
|
| 2064 |
testing::internal::CaptureStdout(); |
| 2065 |
|
| 2066 |
const size_t numTimeSteps = 2; |
| 2067 |
for (size_t timeStep = 0; timeStep < numTimeSteps; ++timeStep) { |
| 2068 |
write_scalar_field_on_device(stkField, 3.14+timeStep); |
| 2069 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2070 |
} |
| 2071 |
|
| 2072 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2073 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 2074 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 2075 |
check_no_warnings(stdoutString); |
| 2076 |
} |
| 2077 |
|
| 2078 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleAccesses_ProperlySyncToHost_NoWarning) |
| 2079 |
{ |
| 2080 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2081 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2082 |
{1, "Part2"}}); |
| 2083 |
|
| 2084 |
testing::internal::CaptureStdout(); |
| 2085 |
|
| 2086 |
write_scalar_field_on_device(stkField, 3.14); |
| 2087 |
stkField.modify_on_device(); |
| 2088 |
stkField.sync_to_host(); |
| 2089 |
|
| 2090 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2091 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2092 |
|
| 2093 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2094 |
check_no_warnings(stdoutString); |
| 2095 |
} |
| 2096 |
|
| 2097 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleStaleAccesses_MissingAllModifySyncCallsToHost_Warning) |
| 2098 |
{ |
| 2099 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2100 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2101 |
{1, "Part2"}}); |
| 2102 |
|
| 2103 |
testing::internal::CaptureStdout(); |
| 2104 |
|
| 2105 |
write_scalar_field_on_device(stkField, 3.14); |
| 2106 |
|
| 2107 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2108 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2109 |
|
| 2110 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2111 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 2112 |
extract_warning(stdoutString, 2, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 2113 |
check_no_warnings(stdoutString); |
| 2114 |
} |
| 2115 |
|
| 2116 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleWrites_ProperlySyncToHost_NoWarning) |
| 2117 |
{ |
| 2118 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2119 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2120 |
{1, "Part2"}}); |
| 2121 |
|
| 2122 |
testing::internal::CaptureStdout(); |
| 2123 |
|
| 2124 |
write_scalar_field_on_device(stkField, 3.14); |
| 2125 |
write_scalar_field_on_device(stkField, 2.18); |
| 2126 |
stkField.modify_on_device(); |
| 2127 |
stkField.sync_to_host(); |
| 2128 |
|
| 2129 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2130 |
|
| 2131 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2132 |
check_no_warnings(stdoutString); |
| 2133 |
} |
| 2134 |
|
| 2135 |
TEST_F(NgpDebugFieldSync, ScalarAccessUsingBucket_MultipleWrites_MissingAllModifySyncCallsToHost_Warning) |
| 2136 |
{ |
| 2137 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2138 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{1, "Part1"}, |
| 2139 |
{1, "Part2"}}); |
| 2140 |
|
| 2141 |
testing::internal::CaptureStdout(); |
| 2142 |
|
| 2143 |
write_scalar_field_on_device(stkField, 3.14); |
| 2144 |
write_scalar_field_on_device(stkField, 2.18); |
| 2145 |
|
| 2146 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2147 |
|
| 2148 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2149 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=10"); |
| 2150 |
extract_warning(stdoutString, 1, "WARNING: Accessing stale data on Host for Field doubleScalarField[0]=20"); |
| 2151 |
check_no_warnings(stdoutString); |
| 2152 |
} |
| 2153 |
|
| 2154 |
|
| 2155 |
#ifndef STK_DEBUG_FIELD_SYNC |
| 2156 |
TEST_F(NgpDebugFieldSync, DefaultDebugger_ScalarAccessUsingEntity_ProperlySyncToDevice_NoWarning) |
| 2157 |
{ |
| 2158 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2159 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field_default_debugger<double>("doubleScalarField", {{2, "Part1"}}); |
| 2160 |
|
| 2161 |
testing::internal::CaptureStdout(); |
| 2162 |
write_scalar_field_on_host_using_entity_default_debugger(stkField, 3.14); |
| 2163 |
stkField.modify_on_host(); |
| 2164 |
stkField.sync_to_device(); |
| 2165 |
|
| 2166 |
read_scalar_field_on_device_default_debugger(stkField); |
| 2167 |
|
| 2168 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2169 |
check_no_warnings(stdoutString); |
| 2170 |
} |
| 2171 |
|
| 2172 |
TEST_F(NgpDebugFieldSync, DefaultDebugger_ScalarAccessUsingEntity_ProperlySyncToHost_NoWarning) |
| 2173 |
{ |
| 2174 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2175 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field_default_debugger<double>("doubleScalarField", {{2, "Part1"}}); |
| 2176 |
|
| 2177 |
testing::internal::CaptureStdout(); |
| 2178 |
write_scalar_field_on_device_default_debugger(stkField, 3.14); |
| 2179 |
stkField.modify_on_device(); |
| 2180 |
stkField.sync_to_host(); |
| 2181 |
|
| 2182 |
read_scalar_field_on_host_using_entity_default_debugger(stkField); |
| 2183 |
|
| 2184 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2185 |
check_no_warnings(stdoutString); |
| 2186 |
} |
| 2187 |
|
| 2188 |
TEST_F(NgpDebugFieldSync, DefaultDebugger_ScalarAccessUsingEntity_MeshModification_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 2189 |
{ |
| 2190 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2191 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field_default_debugger<double>("doubleScalarField", {{2, "Part1"}, |
| 2192 |
{1, "Part2"}}); |
| 2193 |
|
| 2194 |
testing::internal::CaptureStdout(); |
| 2195 |
modify_element_part_membership({{2, "Part2", "Part1"}}); |
| 2196 |
|
| 2197 |
write_scalar_field_on_host_using_entity_default_debugger(stkField, 3.14); |
| 2198 |
stkField.modify_on_host(); |
| 2199 |
stkField.sync_to_device(); |
| 2200 |
|
| 2201 |
read_scalar_field_on_device_default_debugger(stkField); |
| 2202 |
|
| 2203 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2204 |
check_no_warnings(stdoutString); |
| 2205 |
} |
| 2206 |
|
| 2207 |
TEST_F(NgpDebugFieldSync, DefaultDebugger_ScalarAccessUsingEntity_MeshModification_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 2208 |
{ |
| 2209 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2210 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field_default_debugger<double>("doubleScalarField", {{2, "Part1"}, |
| 2211 |
{1, "Part2"}}); |
| 2212 |
|
| 2213 |
testing::internal::CaptureStdout(); |
| 2214 |
|
| 2215 |
write_scalar_field_on_device_default_debugger(stkField, 3.14); |
| 2216 |
stkField.modify_on_device(); |
| 2217 |
stkField.sync_to_host(); |
| 2218 |
|
| 2219 |
modify_element_part_membership({{2, "Part2", "Part1"}}); |
| 2220 |
|
| 2221 |
read_scalar_field_on_host_using_entity_default_debugger(stkField); |
| 2222 |
|
| 2223 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2224 |
check_no_warnings(stdoutString); |
| 2225 |
} |
| 2226 |
|
| 2227 |
TEST_F(NgpDebugFieldSync, DefaultDebugger_HostField_UsageNotProblematic) |
| 2228 |
{ |
| 2229 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2230 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field_default_debugger<double>("doubleScalarField", {{2, "Part1"}}); |
| 2231 |
stk::mesh::HostField<double> hostField(get_bulk(), stkField); |
| 2232 |
|
| 2233 |
testing::internal::CaptureStdout(); |
| 2234 |
write_scalar_host_field_on_device(hostField, 3.14); |
| 2235 |
read_scalar_field_on_host_using_entity_default_debugger(stkField); |
| 2236 |
|
| 2237 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2238 |
check_no_warnings(stdoutString); |
| 2239 |
} |
| 2240 |
#endif |
| 2241 |
|
| 2242 |
TEST_F(NgpDebugFieldSync, ForcedDebugger_HostField_UsageNotProblematic_UsingEntity) |
| 2243 |
{ |
| 2244 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2245 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 2246 |
stk::mesh::HostField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> hostField(get_bulk(), stkField); |
| 2247 |
|
| 2248 |
testing::internal::CaptureStdout(); |
| 2249 |
write_scalar_host_field_on_device<double, NgpDebugger>(hostField, 3.14); |
| 2250 |
read_scalar_field_on_host_using_entity(stkField); |
| 2251 |
|
| 2252 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2253 |
check_no_warnings(stdoutString); |
| 2254 |
} |
| 2255 |
|
| 2256 |
TEST_F(NgpDebugFieldSync, ForcedDebugger_HostField_UsageNotProblematic_UsingBucket) |
| 2257 |
{ |
| 2258 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2259 |
stk::mesh::Field<double> & stkField = build_mesh_with_scalar_field<double>("doubleScalarField", {{2, "Part1"}}); |
| 2260 |
stk::mesh::HostField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> hostField(get_bulk(), stkField); |
| 2261 |
|
| 2262 |
testing::internal::CaptureStdout(); |
| 2263 |
write_scalar_host_field_on_device<double, NgpDebugger>(hostField, 3.14); |
| 2264 |
read_scalar_field_on_host_using_bucket(stkField); |
| 2265 |
|
| 2266 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2267 |
check_no_warnings(stdoutString); |
| 2268 |
} |
| 2269 |
|
| 2270 |
class NgpDebugFieldSync_SeparateFieldRestrictions : public NgpDebugFieldSyncFixture |
| 2271 |
{ |
| 2272 |
public: |
| 2273 |
void setup_mesh_and_field_with_multiple_restrictions(const std::string& fieldName) |
| 2274 |
{ |
| 2275 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2276 |
get_meta().enable_field_sync_debugger(); |
| 2277 |
stk::mesh::Part& part1 = get_meta().declare_part_with_topology("Part1", stk::topology::HEX_8); |
| 2278 |
stk::mesh::Part& part2 = get_meta().declare_part_with_topology("Part2", stk::topology::HEX_8); |
| 2279 |
|
| 2280 |
const unsigned numStates = 1; |
| 2281 |
stk::mesh::Field<double> & field = get_meta().declare_field<double>(stk::topology::ELEM_RANK, fieldName, numStates); |
| 2282 |
|
| 2283 |
stk::mesh::put_field_on_mesh(field, part1, nullptr); |
| 2284 |
stk::mesh::put_field_on_mesh(field, part2, nullptr); |
| 2285 |
|
| 2286 |
const std::vector<PartConfiguration> part1FullPart2Empty = {{"Part1", 2}}; |
| 2287 |
build_mesh(part1FullPart2Empty); |
| 2288 |
} |
| 2289 |
|
| 2290 |
void force_creation_of_last_mod_location_field() |
| 2291 |
{ |
| 2292 |
get_bulk().modification_begin(); |
| 2293 |
get_bulk().modification_end(); |
| 2294 |
} |
| 2295 |
}; |
| 2296 |
|
| 2297 |
TEST_F(NgpDebugFieldSync_SeparateFieldRestrictions, MeshMod_EmptyPart_NoWarning) |
| 2298 |
{ |
| 2299 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { GTEST_SKIP(); } |
| 2300 |
|
| 2301 |
std::string fieldName("doubleScalarField"); |
| 2302 |
setup_mesh_and_field_with_multiple_restrictions(fieldName); |
| 2303 |
stk::mesh::Field<double> & stkField = initialized_field<double>(fieldName); |
| 2304 |
|
| 2305 |
testing::internal::CaptureStdout(); |
| 2306 |
force_creation_of_last_mod_location_field(); |
| 2307 |
|
| 2308 |
write_scalar_field_on_host_using_entity(stkField, 3.14); |
| 2309 |
|
| 2310 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2311 |
check_no_warnings(stdoutString); |
| 2312 |
} |
| 2313 |
|
| 2314 |
} |