This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget] Allow calls to omp_target_memcpy with 0 size.
ClosedPublic

Authored by grokos on Jan 5 2021, 8:39 AM.

Details

Summary

Currently, calling omp_target_memcpy with 0 size is treated as an error and the function returns OFFLOAD_FAIL. However, there is nothing in the standard prohibiting a 0-length memcpy. This patch changes the current behavior and makes omp_target_memcpy return immediately with OFFLOAD_SUCCESS if length is 0.

Diff Detail

Event Timeline

grokos requested review of this revision.Jan 5 2021, 8:39 AM
grokos created this revision.

Semantic change is good.

Did you consider putting the equal zero test within the existing <= condition? Length zero should be infrequent (and when statically detected we should elide the call), so we can have one fewer conditional branch on the hot path. Probably in the noise though.

grokos updated this revision to Diff 314683.Jan 5 2021, 12:06 PM

Slight optimization - removed condition from the hot path.

This revision is now accepted and ready to land.Jan 5 2021, 2:15 PM
This revision was landed with ongoing or failed builds.Jan 5 2021, 4:07 PM
This revision was automatically updated to reflect the committed changes.