CUDA Kernel -- 2

Job ID: 34853050

Budget: €30 – €200 EUR

Define an object as an array of dimensions [m], where m is typically very big (~10k). Every element of this array is a boolean 0 or 1.

We also have a float value r.

I want a function receiving two objects and computing a new object doing the following:

input_obj = [object1, object2]
idx = 0

for i in 0:m{
if rand() < r then idx = 1 - idx (swap object)
resulting_obj[i] = input_obj[idx][i]
}

return resulting_obj


And this should be done parallelly for n objects, so input is (n, 2, m), output is (n, m).
Also n is big (~1k).


Assumption 1 -> r is very small, thus swapping happens rarely. You should performs optimistic computation (supposing swapping doesn’t happens, and if it happens correct later)



Since the sequentiality along m, I don’t know if it is better to do blocks through m and threads through n or vice versa.
You can swap axes to have contiguous memory (instead of input (n, 2, m) you can have it (m, 2, n), but also the output should be (m, n) in this case).
Related categories: C Programming CUDA C++ Programming