'OpenCL Exception: Could not compile program

In general - I am a complete 0 in OpenCL and ILGPU (Here it will not be said about it) I have a sufficiently optimized program to calculate the sum of all outcomes of a function (Probably this is stupid, but the function is very complex and is a random function in Java).
The program works with the CPU in multi-threaded mode (Thanks @aepot).
Now I am running out of time to calculate this number (Sum of all outcomes), which is why the calculations on the CPU are not irrational, because my processor is weak, and it takes a lot of time.
Because of what I want to transfer the calculations to the GPU, I already tried ILGPU, but there were problems with the connection, and then with work.
Now a friend advised me OpenCL (It wins in terms of speed, I don’t have CUDA), so I started doing something on it. What I just did - does not work.

Calculation code in the form of OpenCL:

        private static string s = @"
        kernel void GenChunk(global int * x, global int * z, global int * count, global long * a, global long * b)
        {
            long chunkSeed = ((x[0] * 0x4F9939F508 + z * 0x1EF1565BD5) ^ 0x5DEECE66D) & 0xFFFFFFFFFFFF;
            int vx = x[0] >> 4;
            int vz = z[0] >> 4;
            for (int y = 1; y < 5; y += 1){
                for (int bx = vx; bx < vx + 16; bx += 1){
                    for (var bz = vz; bz < vz + 16; bz += 1){
                        if (Gen(bx, y, bz, chunkSeed)){
                            count[0] += 1;}}}}
        }
        kernel bool Gen(global int * x, global int * y, global int * z, global int * seed)
        {
            long pi = (((z[0] & 0xF) * 0x10) + (x[0] & 0xF)) * 4 + (3 - (y[0] - 1));
            return ((((seed[0] * A[pi] + B[pi]) & 0xFFFFFFFFFFFF) >> 0x11) % 5) >= y[0];
        }
        ";

The code to call this miracle:

public static void Start(long[] arg)
{
    CLCalc.InitCL();
    CLCalc.Program.Compile(new string[] { s }); // get error Could not compile program
    int[] max = new int[] { 1 };
    CLCalc.Program.Kernel genChunk = new CLCalc.Program.Kernel("GenChunk");
    Help h = new Help(new Info((int)arg[0], arg[1], new Point((int)arg[2], (int)arg[3], (int)arg[4]), new Point((int)arg[5], (int)arg[6], (int)arg[7])));
    for (; h.i.x < MaxBlock; h.i.x++)
    {
        varz = -1875000;
        var startTime = DateTime.Now;
        for (; z < MaxBlock; z++)
        {
            CLCalc.Program.Variable xarg = new CLCalc.Program.Variable(new int[] { h.i.x });
            CLCalc.Program.Variable zarg = new CLCalc.Program.Variable(new int[] { z });
            CLCalc.Program.Variable countarg = new CLCalc.Program.Variable(new int[] { 0 });
            CLCalc.Program.Variable a = new CLCalc.Program.Variable(A_OW_112);
            CLCalc.Program.Variable b = new CLCalc.Program.Variable(B_OW_112);
            CLCalc.Program.Variable[] genArgs = { xarg, zarg, countarg, a, b };
            genChunk.Execute(genArgs, max);
            int[] tempCount = new int[1] { 0 };
            countarg.ReadFromDeviceTo(tempCount);
            h.i.count += tempCount[0];
            Console.WriteLine(tempCount[0]);
        }
        h.Save(@"C:\\p.txt", h.i.x + 1, h.i.count, h.i.min, h.i.max, startTime, 0, 0);
    }
}

A_OW_112 and B_OW_112 are long arrays, both of 1024 values, I pass them as a parameter, but I would like to write them into s (OpenCL code) so that it all goes many times faster (Unless of course this still happens, everything seems to be pointers there) Standard calculation on the CPU:

private const int MaxBlock = 0x1C9C38;
    public void Start(long[] args)
    {
        Help h = new Help(new Info((int)args[0], args[1], new Point((int)args[2], (int)args[3], (int)args[4]), new Point((int)args[5], (int)args[6], (int)args[7])));
        for (; h.i.x < MaxBlock; h.i.x++)
        {
            varz = -1875000;
            var startTime = DateTime.Now;
            for (; z < MaxBlock; z++) h.i.count += h.GetBedrockChunk(h.i.x, z);
            h.Save(@"C:\\p.txt", h.i.x + 1, h.i.count, h.i.min, h.i.max, startTime, 0, 0);
        }
    }
        internal static bool bO112(in int x, in byte y, in int z, in long cs)
    {
        var pi = (((z & 0xF) * 0x10) + (x & 0xF)) * 4 + (3 - (y - 1));
        return ((((cs * A_OW_112[pi] + B_OW_112[pi]) & 0xFFFFFFFFFFFF) >> 0x11) % 5) >= y;
    }
    public Help(Info info)
    {
        this.i = info;
    }
    private const int MaxBlock = 0x1C9C38;
    public info i;
    private readonly CultureInfo de = new CultureInfo("de-DE");
    private readonly object _lock = new object();

    public long GetBedrockChunk(int x, int z)
    {
        var countBedrockInChunk = 0;
        var chunkSeed = ((x * 0x4F9939F508 + z * 0x1EF1565BD5) ^ 0x5DEECE66D) & 0xFFFFFFFFFFFF;
        var vx = x >> 4;
        var vz = z >> 4;
        for (var y = (byte)1; y < 5; y += 1)
            for (var bx = vx; bx < vx + 16; bx += 1)
                for (var bz = vz; bz < vz + 16; bz += 1)
                    if (BedrockGen.bO112(bx, y, bz, chunkSeed))
                        countBedrockInChunk +=one;
        lock(_lock)
        {
            if (countBedrockInChunk > i.max.count)
            {
                Write(ConsoleColor.Green, "Max " + "[" + i.max.count + "->" + countBedrockInChunk + "] [" + x + "|" + z+ "] [" + (i.count + countBedrockInChunk ).ToString("#,#", de) + "]");
                i.max = new Point(x, z, countBedrockInChunk);
            }
            else if (countBedrockInChunk < i.min.count)
            {
                Write(ConsoleColor.Red, "Min " + "[" + i.min.count + "->" + countBedrockInChunk + "] [" + x + "|" + z + "] [" + (i.count + countBedrockInChunk).ToString("#,#", de) + "]");
                i.min = new Point(x, z, countBedrockInChunk);
            }
            else if(countBedrockInChunk > 600)
                Write(ConsoleColor.Gray, "rMax " + "[" + countBedrockInChunk + "] [" + x + "|" + z + "] [" + (i.count + countBedrockInChunk).ToString("#,#", de) + "]");
            else if(countBedrockInChunk < 400)
                Write(ConsoleColor.Gray, "rMin " + "[" + countBedrockInChunk + "] [" + x + "|" + z + "] [" + (i.count + countBedrockInChunk).ToString("#,#", de) + "]");
        }
        return countBedrockInChunk;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Send(ConsoleColor color, string message)
    {
        Console.ForegroundColor = color;
        Console.WriteLine("[" + DateTime.Now.ToString("yy.MM.dd.HH:mm:ss") + "] " + message);
    }
    private void Write(ConsoleColor color, string message)
    {
        File.AppendAllLines("C:\\p2.txt", new string[] { message }, Encoding.Default);
        send(color, message);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Save(string path, int x, long countBedrockArg, Point coordinatesMinBedrockCountArg, Point coordinatesMaxBedrockCountArg, DateTime dateStart, int firstArg, int secondArg)
    {
        File.WriteAllText(path,
            string.Join(',',
                new long[]{
                    x, countBedrockArg, coordinatesMinBedrockCountArg.x, coordinatesMinBedrockCountArg.z,
                    coordinatesMinBedrockCountArg.count, coordinatesMaxBedrockCountArg.x,
                    coordinatesMaxBedrockCountArg.z,
                    coordinatesMaxBedrockCountArg.count, firstArg, secondArg
                }.Select(x => x.ToString())));
        Send(ConsoleColor.Yellow, $"Save [{x}({ Math.Round((float)(100 - (float)Math.Abs(x) / MaxBlock * 100 + (x > 0 ? 50 : 0)), 5, MidpointRounding.AwayFromZero)}%)] [{(new TimeSpan((DateTime.Now - dateStart).Ticks).ToString("mm'm 'ss's 'fff'n'").Replace("00s ", " ").Replace("00m ", "").Replace("000n", ""))}] [{i.count.ToString("#,#", new CultureInfo("de-DE"))} ]");
    }



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source