2

I am trying to convert a recursive algorithm from CPU to GPU using ALEA Library. I get the following errors if I build the code :

"Fody/Alea.CUDA: AOTCompileServer exited unexpectly with exit code -1073741571"

public class GPUModule : ILGPUModule
{
 public GPUModule (GPUModuleTarget target) : base(target)
 {
 }

 [Kernel]  //Same Error whether RecursionTest is another Kernel or not.
 public void RecursionTest(deviceptr<int> a)
 {
   ...
   RecursionTest(a);
 }

 [Kernel]
 public MyKernel(deviceptr<int> a, ...)
 {
   ...
   var a = __shared__.Array<int>(10);
   RecursionTest(Intrinsic.__array_to_ptr<int>(a)); //Error here
 }
 ...
}

I will appreciate if you provide any documentation or link for recursion examples in C# using ALEA Library.

Thanks in advance

1 Answers1

1

You are using Alea GPU 2.x, the newest version is Alea GPU 3.x. (see www.aleagpu.com). With 3.0, I made a test and it works:

using Alea;
using Alea.CSharp;
using NUnit.Framework;

    public static void RecursionTestFunc(deviceptr<int> a)
    {
        if (a[0] == 0)
        {
            a[0] = -1;
        }
        else
        {
            a[0] -= 1;
            RecursionTestFunc(a);
        }
    }

    public static void RecursionTestKernel(int[] a)
    {
        var tid = threadIdx.x;
        var ptr = DeviceFunction.AddressOfArray(a);
        ptr += tid;
        RecursionTestFunc(ptr);
    }

    [Test]
    public static void RecursionTest()
    {
        var gpu = Gpu.Default;
        var host = new[] {1, 2, 3, 4, 5};
        var length = host.Length;
        var dev = gpu.Allocate(host);
        gpu.Launch(RecursionTestKernel, new LaunchParam(1, length), dev);
        var actual = Gpu.CopyToHost(dev);
        var expected = new[] {-1, -1, -1, -1, -1};
        Assert.AreEqual(expected, actual);
        Gpu.Free(dev);
    }
Xiang Zhang
  • 2,831
  • 20
  • 40
  • Here is the version list for ALEA dependencies : ALEA.dll (v4.0.30319 / 3.0.0.0) ALEA.CUDA.dll (v4.0.30319 / 2.2.0.3307) Alea.CUDA.IL.dll (v4.0.30319 / 2.2.0.3307) Alea.IL.dll (v4.0.30319 / 2.2.0.3307) I guess this is version 3 – Mehmet Bingöl Jan 30 '17 at 09:58
  • No, that is version 2.2.0 (actually, I think you are a little messed up with alea.dll, that comes from version 3, but the others are from version 2), please go to here: http://www.quantalea.com/ (under the menu "Products", there are links to version 3). – Xiang Zhang Jan 30 '17 at 10:26
  • Yes it is a mess because It took weeks to be able to fix the compilation errors like weaver.xml. There isn't enough documentation in ALEA's web site regarding the installation process and possible error messages. So I had to arbitrarily try different settings and versions. Please take me through the installation process so that I can implement Class Instance-Based GPU Coding. The latest ALEA.CUDA and ALEA.CUDA.IL versions in Nuget are 2.2.0.3307. ALEA.IL version became 3.0.0.0 now after reinstalling it through Nuget. But I still get the same error message. – Mehmet Bingöl Jan 30 '17 at 15:46
  • By the way thank you very much for spending time for a working recursive code. I tested it in my project with the above references and it also worked. I assume the error can be related with class instance based GPU Coding and/or CUDA references. Can you try such an example for me please? – Mehmet Bingöl Jan 30 '17 at 16:28
  • Class instance based coding is in Alea V2.2. In V3 it is much simpler. Check the samples on the [gallery](http://www.aleagpu.com/gallery.html). For installation of V3 see [here](http://www.aleagpu.com/installation.html) – Daniel Jan 30 '17 at 16:33
  • After looking into the Build Log in output window, I noticed the following error before the "AOTCompileServer exited unexpectly with exit code -1073741571" error : [ERROR] System.Runtime.Remoting.RemotingException: Failed to read from an IPC Port: The pipe has been ended. – Mehmet Bingöl Jan 30 '17 at 17:38
  • @XiangZhang, I converted my code to method based GPU coding for recursion. But my application crashes if I try to debug it. If I comment out the recursion line I can debug. It crashes if I have any Console.Writeln command as well. I also receive System.AccessViolationException if I access array "a" after RecursionTestFunc(a); Maybe I should ask this with a new question. – Mehmet Bingöl Feb 07 '17 at 21:14
  • @MehmetBingöl, yes, please make a new question and put your code there, btw, alea gpu version 2.x will not be supported anymore, I strongly suggest you go with version 3.x – Xiang Zhang Feb 09 '17 at 10:15
  • @XiangZhang, These are the reference versions. How do we understand that I am using Version 2.x? Alea, Version=3.0.0.0 Alea.Cuda Version = 2.2.0.3307 (this is the latest in git) Alea.IL, Version = 3.0.0.0 Alea.Parallel, Version = 3.0.0.0 FSharp.Core, Version = 4.4.0.0 unit.framework Version = 2.6.3.13283 This is what I get when I install through GIT – Mehmet Bingöl Feb 09 '17 at 14:40
  • @MehmetBingöl, I think you messed up a little bit the packages. There is only two packages for AleaGPU 3.x: Alea and Alea.Fody. Please double check your packages, leave package Alea and Alea.Fody, and get rid of all other packages such as Alea.CUDA, etc, they are all old. – Xiang Zhang Feb 09 '17 at 14:57
  • @XiangZhang, ALEA.CUDA is used in the examples you have shown in your page "First Alea GPU Program". I am using it for Common.divup function. Is there a newer version of it in 3.x? I removed other references. They were not necessary. – Mehmet Bingöl Feb 09 '17 at 16:48