AlexVlx wrote:

> Well, it's certainly used that way in existing CUDA code and it's been around 
> forever: Here are few random examples:
> 
> * from both 10 years ago:
>   
> https://stackoverflow.com/questions/20535683/cuda-5-5-cudamemcpytosymbol-constant-and-out-of-scope-error
> * fairly recent example: 
> https://forums.developer.nvidia.com/t/constant-memory-cudamemcpytosymbol-and-compilation-units/248780

Hmm, neither of those illustrates what I was getting at / both would still work 
just the same even with this change, I think. Because the `memcpyToSymbol`s 
would always be sequenced before the actual kernel dispatch expected to observe 
the modified values, and since these remain `externally_initialized` it should 
be fine (empirically, this appears to work as expected). 

Also, turns out that the case I was considering (kernel executes concurrently 
with updates to a `__constant__` variable it is accessing) is explicitly called 
out as UB by CUDA under 10.2.2: `The behavior of modifying a constant from the 
host while there is a concurrent grid that access that constant at any point of 
this grid’s lifetime is undefined.`, so we're safe from that at least.

https://github.com/llvm/llvm-project/pull/110182
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to