Is there any way to cast metal::atomic_intto int in MSLibrary like C++ Standard Library ?
C++:
MSL:
C++:
Code Block std::atomic<int> atom {10}; int num = (int)atom;
MSL:
Code Block kernel void compute_shader (device metal::atomic_int& incremental [[buffer(0)]],threadgroup atomic_int& local [[threadgroup(0)]],ushort lid [[thread_position_in_threadgroup]] ){ atomic_fetch_add_explicit(&local, 1, memory_order_relaxed); threadgroup_barrier(mem_flags::mem_threadgroup); if(lid == 0) { atomic_fetch_add_explicit(&incremental, (int)local, memory_order_relaxed);//ERROR atomic_fetch_add_explicit(&incremental, as_type<int>(local), memory_order_relaxed);//ERROR } }