i have to write program, but i dont have a clue how 2 do it, this is small riddle for CUDA developers :
thx 4 answers :)
i need to write a program which search divisors of given number
on input program expecting on natural number ‘y’, for this number ‘y’ need to check n=floor(srt(y)) divisors
program need to use a few arrays:
array C,D ,E - arrays type of int, size of n, arrays dont need to be inniciated
algorythm must work on one dimension grid
run n threads
every thread on x number need check, that number ‘y’ can be devided by x+1(we dont want divide by 0).
if number y can be devided by x+1, thread should save to array C, under position x value 1, else save 0
use EXCLUSIVE SCAN using sum operator on array C, results save to array D.
run again n threads
every thread with number x in grid, should check that in array C, under position x in saved 1 or 0.
if 0, thread dont need to do nothing, but if is 1, thread should read from array D from x position value ‘i’, next
should save to array E, under position ‘i’ , number x+1
array E keep list od founded divisors of figure(number) ‘y’. amount of founded divisors is equal sum of last
element of array C and last element of array D.