diff --git a/add-types.sh b/data/add_types.sh similarity index 100% rename from add-types.sh rename to data/add_types.sh diff --git a/runtime/pairs.cpp b/runtime/pairs.cpp index 1fda232e7f239f137531bc3d1c6ce40f15a5587a..6bae0491271b28d438cd6fe1fc9aeecbaca713fd 100644 --- a/runtime/pairs.cpp +++ b/runtime/pairs.cpp @@ -130,6 +130,11 @@ void PairsSimulation::copyPropertyToHost(Property &prop) { } } +void PairsSimulation::copyFeaturePropertyToDevice(FeatureProperty &feature_prop) { + PAIRS_DEBUG("Copying static array %s to device\n", feature_prop.getName().c_str()); + pairs::copy_static_symbol_to_device(feature_prop.getHostPointer(), feature_prop.getDevicePointer(), feature_prop.getArraySize()); +} + void PairsSimulation::communicateSizes(int dim, const int *send_sizes, int *recv_sizes) { auto nsend_id = getArrayByHostPointer(send_sizes).getId(); auto nrecv_id = getArrayByHostPointer(recv_sizes).getId(); diff --git a/runtime/pairs.hpp b/runtime/pairs.hpp index 6c82e67675bfe75ccdf373e1cf1e8d8384ae6da9..8c8be73ebb42e5476b5793dad2b8bd16af1a6bb2 100644 --- a/runtime/pairs.hpp +++ b/runtime/pairs.hpp @@ -115,6 +115,9 @@ public: void copyPropertyToHost(property_t id) { copyPropertyToHost(getProperty(id)); } void copyPropertyToHost(Property &prop); + void copyFeaturePropertyToDevice(property_t id) { copyFeaturePropertyToDevice(getFeatureProperty(id)); } + void copyFeaturePropertyToDevice(FeatureProperty &feature_prop); + void communicateSizes(int dim, const int *send_sizes, int *recv_sizes); void communicateData( int dim, int elem_size, diff --git a/src/pairs/code_gen/cgen.py b/src/pairs/code_gen/cgen.py index cd932211389161f68823a6d43d9bc5629ebc5469..4e7c43123a4cc264c54d261abd24af9d63a50518 100644 --- a/src/pairs/code_gen/cgen.py +++ b/src/pairs/code_gen/cgen.py @@ -539,11 +539,14 @@ class CGen: assert fptype != "Prop_Invalid", "Invalid feature property type!" self.print(f"{tkw} {ptr}[{array_size}];") - self.print(f"pairs->addFeatureProperty({fp.id()}, \"{fp.name()}\", &{ptr}, {d_ptr}, {fptype}, {nkinds}, {array_size});") + self.print(f"pairs->addFeatureProperty({fp.id()}, \"{fp.name()}\", &{ptr}, {d_ptr}, {fptype}, {nkinds}, {array_size} * sizeof({tkw}));") for i in range(array_size): self.print(f"{ptr}[{i}] = {fp.data()[i]};") + if self.target.is_gpu() and fp.device_flag: + self.print(f"pairs->copyFeaturePropertyToDevice({fp.id()}); // {fp.name()}") + if isinstance(ast_node, Timestep): self.generate_statement(ast_node.block)