I wanted to get line coordinates from startpoint to endpoint, but it didn’t work. I guess that the problem is in data type of Segment
list(and overally a lists).
In my program I will use lists to load data.
using CUDAdrv
using CUDAnative
function divideLine(Segment,numberofsegments,SegmentsCalculated)
numberOfElement = (blockIdx().x-1) * blockDim().x + threadIdx().x
segmentNumber = (blockIdx().y-1) * blockDim().y + threadIdx().y
coor = (blockIdx().z-1) * blockDim().z + threadIdx().z
SegmentsCalculated[numberOfElement][segmentNumber][coor]=Segment[segmentNumber][1][coor]+(segmentNumber-1)%numberofsegments*(Segment[segmentNumber][2][coor]-Segment[segmentNumber][1][coor])/(numberofsegments-1)
return nothing
end
numberofsegments=100
Segment=[]
startline1=Float32[-500.0,0.0,1.0]
endline1=Float32[500.0,0.0,1.0]
startline2=Float32[0.0.-500,0.0,1.0]
endline2=Float32[0.0,500.0,1.0]
push!(Segment,[startline1,endline1])
push!(Segment,[startline2,endline2])
SegmentsCalculated=similar(Segment)
optimalBlocks=2*attribute(CuDevice(0),CUDAdrv.MULTIPROCESSOR_COUNT)
@cuda blocks=1,optimalBlocks,1 threads=length(S),numberofsegments/optimalBlocks,3 divideLine(Segment,numberofsegments,SegmentsCalculated)
ERROR: GPU compilation of divideLine(Array{Any,1}, Int64, Array{Any,1}) failed
KernelError: passing and using non-bitstype argument
Argument 2 to your kernel function is of type Array{Any,1}.
That type is not isbits, and such arguments are only allowed when they are unused by the kernel.
What’s the easiest way to avoid this?