chrisanonym

accessing LDS memory problem

Discussion created by chrisanonym on May 17, 2009
Latest reply on Nov 5, 2009 by emuller

Hello,

I 'm trying to run the following simple kernel code:

Attribute[GroupSize(64)]
kernel void sum(int4 a<>, int4 b<>, out int4 c[]){
    shared int4 lds[64];

    int index = instance().x;
    lds[index] = instance();
    c[index] = lds[index];
}

 

while I 'm using the following code for the main function:

 

#include <iostream>
#include "brookgenfiles/kernels.h"

using namespace std;

int main(void){
    int4 cpu_a[64];
    int4 cpu_b[64];
    int4 cpu_c[64];
    unsigned int streamSize[] = {64};
    unsigned int rank = 1;

    brook::Stream<int4> gpu_a(rank, streamSize);
    brook::Stream<int4> gpu_b(rank, streamSize);
    brook::Stream<int4> gpu_c(rank, streamSize);

    gpu_a.read(cpu_a);
    gpu_b.read(cpu_b);

    sum(gpu_a, gpu_b, gpu_c);
    if(gpu_c.error()){
        cout << gpu_c.errorLog();
        return 1;
    }
    gpu_c.write(cpu_c);
    for(int i=0;i<64;i++)
        cout << "(" << cpu_c.x << ", " << cpu_c.y << ", " << cpu_c.z << ", " << cpu_c.w << ")\n";
    cout << "\n\n";
    return 0;
}

 

The results tha I 'm getting is the tupple (0, 0, 0, 0) for every element of stream C, which are obviously unexpected (see bold lines of the kernel code).

Am I doing something wrong?

 

Outcomes