I have a simple question. Is it possible to write structures of arrays like this with Alea.Gpu?
public struct SVDFactorsStructGpu
{
public deviceptr<float> ItemsBiases;
public deviceptr<float> UsersBiases;
public deviceptr<float> ItemsFeatures;
public deviceptr<float> UsersFeatures;
}
[...]
SVDFactorsStructGpu factors = new SVDFactorsStructGpu();
factors.ItemsBiases = gpuItemsBiases.Ptr;
factors.UsersBiases = gpuUsersBiases.Ptr;
factors.ItemsFeatures = gpuItemsFeatures.Ptr;
factors.UsersFeatures = gpuUsersFeatures.Ptr;
[...]
And pass them somehow like this to a kernel:
public void TrainEpochKernel(SVDParamsStructGpu svdParams,
deviceptr<float> ratings,
deviceptr<int> ratingsItemsIds,
deviceptr<int> userProfilesIds,
deviceptr<int> ratingsStartIdxs,
deviceptr<int> ratingsCounts,
deviceptr<float> userProfilesSSE,
SVDFactorsStructGpu factors)
{
int startUserProfileIdx = blockIdx.x * (blockDim.x * svdParams.StridePerThread) + threadIdx.x * svdParams.StridePerThread;
[...]
pred = svdParams.GlobalMean;
pred += factors.ItemsBiases[i];
pred += factors.UsersBiases[u];
[...]
This works without a structure but yields an illegal address when encapsulated.
Thanks in advance
[edit #1] It seems that the Ptr copy is in cause here, as if I try to pass them from the structure directly in the kernel signature the error is the same.
[edit #2] Maybe it is a very obvious question, I tried to pass the DeviceMemory<> directly but was unable to set values. I am going to keep the "one parameter for one array version" as it is not critical and got a very efficient algorithm overall. Was just curious to know more about Alea.Gpu C#.
Cf, comment above. Everything worked fine with the arrays. :)