views:

43

answers:

2

We are working on a homework on CELL programming for college and their feedback response to our questions is kinda slow, thought i can get some faster answers here.

I have a PPU side code which tries to open a file passed down through char* argv[], however this doesn't work it cannot make the assignment of the pointer, i get a NULL.

Now my first idea was that the file isn't in the correct directory and i copied in every possible and logical place, my second idea is that maybe the PPU wants this pointer in its LS area, but i can't deduce if that's the bug or not. So...

My question is what am i doing wrong?

I am working with a Fedora 7 SDK Cell, with Eclipse as an IDE. Maybe my argument setup is wrong tho he gets the name of the file correctly.

Code on request:

images_t *read_bin_data(char *name)
{
    FILE *file;
    images_t *img;
    uint32_t *buffer;
    uint8_t buf;
    unsigned long fileLen;
    unsigned long i;

    //Open file
    file = (FILE*)malloc(sizeof(FILE));
    file = fopen(name, "rb");
    printf("[Debug]Opening file %s\n",name);
    if (!file)
    {
        fprintf(stderr, "Unable to open file %s", name);
        return NULL;
    }
  //.......

}

Main launch:

int main(int argc,char* argv[]) {
   int i,img_width;
   int modif_this[4] __attribute__ ((aligned(16))) = {1,2,3,4};
   images_t *faces, *nonfaces;

   spe_context_ptr_t ctxs[SPU_THREADS];
   pthread_t threads[SPU_THREADS];
   thread_arg_t arg[SPU_THREADS];
   //intializare img_width
   img_width = atoi(argv[1]);
   printf("[Debug]Img size is %i\n",img_width);
   faces = read_bin_data(argv[3]);
 //.......

}

Thanks for the help.

A: 

Exactly which line is failing, and how?

You should look at errno to see what error is being returned from fopen or other calls.

Also, it should not cause this problem, but you don't need the line:

 file = (FILE*)malloc(sizeof(FILE));

That memory will just be leaked...

Roddy
A: 

I got it, if anyone else had issues with it you have to enable the upload rules and upload the extra-files you desired to be used by the simulator. :)

Cristina