Issue 336/392: enforce max value type sizes to by-value APIs and RPC
Dan Bonachea
Branch: bonachea/upcxx:issue-392-max-value
Branch: berkeleylab/upcxx:develop
Merged
Merged pull request
Merge pull request #245 into develop
Merge pull request #245 into develop
Status
Ready for review.
Example failures:
<>/src/backend.hpp:56:3: error: static assertion failed: This program is attempting to pass an object with a large static type (over 512 bytes) to the by-value overload of upcxx::rput. This is ill-advised because the by-value overload is designed and tuned for small scalar values, and will impose significant data copy overheads (and possibly program stack overflow) when used with larger types. Please use the bulk upcxx::rput overload instead, which manipulates the data by pointer, avoiding costly by-value copies. The threshold for this error can be adjusted (at your own peril!) via -DUPCXX_MAX_VALUE_SIZE=n
<>upcxx/src/rpc.hpp:343:7: error: static assertion failed: This program is attempting to pass an object with a large static type (over 512 bytes) to upcxx::rpc. This is ill-advised because RPC is tuned for top-level argument objects that provide fast move operations, and will impose significant data copy overheads (and possibly program stack overflow) when used with larger types. Please consider instead passing a Serializable container for your large object, such as a upcxx::view (e.g.
upcxx::make_view(&my_large_object, &my_large_object+1)
), to avoid costly data copies. The threshold for this error can be adjusted (at your own peril!) via -DUPCXX_MAX_RPC_ARG_SIZE=nCommits
issue #392: Prevent silent use of by-value communication APIs for huge types
Add static assertions to enforce a default size limit of 512 bytes for types passed to by-value APIs for rget, rput, broadcast and reduce.
The correct resolution is for programs to call the bulk overload instead for statically large objects, but in the interests of backwards compatibility for legacy codes, the limit can also be raised at application compile time via
-DUPCXX_MAX_VALUE_SIZE=n
.Add tests for the new static assertions
issue #336: Add static_assert to prohibit massive types as arguments to RPC
Add static assertions to enforce a default size limit of 512 bytes for types passed as top-level arguments to rpc, rpc_ff and remote_cx::as_rpc.
The correct resolution is for programs to either pass their large-type objects to rpc in a Serializable container (e.g., via
upcxx::make_view
), otherwise arrange to move the data using RMA (for TriviallySerializable data). However in the interests of backwards compatibility for legacy codes, the limit can also be raised at application compile time via-DUPCXX_MAX_RPC_ARG_SIZE=n
.Resolves issue #336
issue #336: Deploy suggested solution in test
Unfortunately this doesn't really solve the problem for types with non-trivial deserialization.
Add tests for the new rpc static assertions
Update ChangeLog