Hi!
I have code like this
struct spin_lock { int spin_; spin_lock(): spin_(0) {}; void enter() restrict(amp) { while(concurrency::atomic_compare_exchange(&spin_, 0, 1) != 0); } void exit() restrict(amp) { concurrency::atomic_exchange(&spin_, 0); } };
And I initialize and use it as follows
spin_lock spinner; array_view<spin_lock, 1> spin_lock(1, &spinner); parallel_for_each(...) { //[...] spin_lock[0].enter(); //[...] spin_lock[0].exit(); //[...] });
And the compiler issues "error C3564: reading uninitialized value when compiling the call graph for the concurrency::parallel_for_each". It looks like I can use freestanding functions and an integer variable instead, but how could I use a struct? I don't discard data when reading the spin_lock view to the GPU and I would think that when the struct is created on the host, i.e. on the CPU, the variable spin_ would be zero-initialized even if the construct weren't called on the GPU and the struct were only bitwise copied over the bus.
Sudet ulvovat -- karavaani kulkee