Closed Ruberik closed 1 week ago
hi @Ruberik, sorry for the late reply.
There are several Amax
overloads on the CuBlas
class for float
.
int Amax(ArrayView1D<float, Stride1D.General> input)
void Amax(ArrayView1D<float, Stride1D.General> input, ArrayView<int> output)
.You are trying to use the second version, which lets you fill an ArrayView.
According to the CuBlas documentation for Amax, the output
can either be host or device
memory.
The important part is that you need to tell CuBlas whether the result buffer is using host or device memory. This is achieved using the CuBlas Pointer Mode.
I was able to reproduce your issue.
And was then able to fix it by calling blas.PointerMode = CuBlasPointerMode.Device;
, just before the call to Amax
.
using var input = accelerator.Allocate1D<float>(DataSize);
using var output = accelerator.Allocate1D<int>(1);
using var blas = new CuBlas(accelerator);
blas.PointerMode = CuBlasPointerMode.Device;
blas.Amax(input.View.AsGeneral(), output.View);
Thanks for the explanation, @MoFtZ! It's unfortunate that this has to be set by hand, but that's a lot better than a crash I can't do anything about. Thanks!
@Ruberik if all your result buffers will be on the GPU, you just have to set it once, at the start.
There is also the other API, which returns the int result, without needing a buffer.
Describe the bug
I get the following crash when I attempt to use Amax(ArrayView1D<float, Stride1D.General> input, ArrayView output):
I suspect the issue may be that my ArrayView is allocated GPU-side, and that perhaps isn't allowed by Cublas.
nvidia-smi output:
Environment
Steps to reproduce
Expected behavior
An int is placed into generalTarget.
Instead there's a crash, as described above.
Additional context
No response