deepakkumar1984 / Amplifier.NET

Amplifier allows .NET developers to easily run complex applications with intensive mathematical computation on Intel CPU/GPU, NVIDIA, AMD without writing any additional C kernel code. Write your function in .NET and Amplifier will take care of running it on your favorite hardware.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runtime Compile Error when using Struct

jiatao99 opened this issue · comments

Got runtime compiling error like the following:

<program source>:39:29: warning: declaration of 'struct Vecter3D' will not be visible outside of this function
 void Compute(global struct Vecter3D* x, global double* y, double a)
                            ^
<program source>:42:16: error: subscript of pointer to incomplete type '__global struct Vecter3D'
        y[num] = a * x[num].x + a * x[num].y + a * x[num].z;
              ~^
<program source>:39:29: note: forward declaration of 'struct Vecter3D'
 void Compute(global struct Vecter3D* x, global double* y, double a)

My struct

    [StructLayout(LayoutKind.Sequential)]
    public struct Vecter3D
    {
        public double x;
        public double y;
        public double z;
    }

Here is the kernal

        [OpenCLKernel]
        public void Compute([Global][Amplifier.OpenCL.StructAttribute] Vecter3D[] x, [Global] double[] y, double a)
        {
            int i = get_global_id(0);
            y[i] = a * x[i].x + a *x[i].y  + a * x[i].z;
        }

Find another bug. If in the OpenCLKernel function I use this code

 int i = get_global_id(0);
  Vecter3D vecter3D = x[i];

I got this error

<program source>:42:23: error: subscript of pointer to incomplete type '__global struct Vecter3D'
        Vecter3D vecter3D = x[num];
commented

Got runtime compiling error like the following:

<program source>:39:29: warning: declaration of 'struct Vecter3D' will not be visible outside of this function
 void Compute(global struct Vecter3D* x, global double* y, double a)
                            ^
<program source>:42:16: error: subscript of pointer to incomplete type '__global struct Vecter3D'
        y[num] = a * x[num].x + a * x[num].y + a * x[num].z;
              ~^
<program source>:39:29: note: forward declaration of 'struct Vecter3D'
 void Compute(global struct Vecter3D* x, global double* y, double a)

My struct

    [StructLayout(LayoutKind.Sequential)]
    public struct Vecter3D
    {
        public double x;
        public double y;
        public double z;
    }

Here is the kernal

        [OpenCLKernel]
        public void Compute([Global][Amplifier.OpenCL.StructAttribute] Vecter3D[] x, [Global] double[] y, double a)
        {
            int i = get_global_id(0);
            y[i] = a * x[i].x + a *x[i].y  + a * x[i].z;
        }

Hi, also getting the same error when using a struct, would you be able to assist further on this issue please?

commented

Hi, so far I've really been enjoying using the library and it stands out above competitor libraries i've tried. The only issue i've encountered has been this. Even the most basic struct I define simply cannot be used. I encounter the same error as above. Is there any updates on this?

@optimus-code Thanks for your feedback. Looking into the struct issue today, will give an update soon

I have updated the example code, I think you missed passing the struct to the compiler so it couldn't find in the kernel. Apologies for less documentation, just working alone on this now :)
image