How can we free GPU memory of an array with AleaGpu ? (on the GPU card)
Inside the function/sub, if we want to free GPU memory of array dOutputs,dInputs, how should we do it ?
1/ Will "dOutputs.Dispose(); dInputs.Dispose();" free the GPU memory ?
2/ Does a "GC.Collect()" for GPU exist ? is it necessary ?
3/ With AleaGpu, do we have a command to free to totaly the GPUmemory ?
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = "";
var worker = Worker.Default;
const int rows = 10;
const int cols = 5;
var rng = new Random();
var inputs = new double[rows, cols];
for (var row = 0; row < rows; ++row)
{
for (var col = 0; col < cols; ++col)
{
inputs[row, col] = rng.Next(1, 100);
}
}
var dInputs = worker.Malloc(inputs);
var dOutputs = worker.Malloc<double>(rows, cols);
var lp = new LaunchParam(1, 1);
worker.Launch(Kernel, lp, dOutputs.Ptr, dInputs.Ptr, rows, cols);
var outputs = new double[rows, cols];
dOutputs.Gather(outputs);
Assert.AreEqual(inputs, outputs);
dOutputs.Dispose();
dInputs.Dispose();"
}
3/ As GPU card have a limited Memory, we need to use Single/Int16/Int32 instead of double. I tried :
var inputs = new Single[rows, cols];
var dOutputs = worker.Malloc<Single>(rows, cols);
var inputs2 = new Int16[rows, cols];
but
worker.Launch(Kernel, lp, dOutputs.Ptr, dInputs.Ptr, rows, cols);
don't to take it. I get error "there is some invalid argument" .
How can we make worker.Launch(Kernel, lp, ...) take Int16,Int32 and single ?