return value from func in flated multiD array

Hi,

I have asked a question in stack overflow (because I had an account there) but I didn’t received any hint

https://stackoverflow.com/questions/47083557/flated-multid-array-for-openacc-pgi

please be so kind and have a look, any hint would help
thank you

Hello,

I am a little confused.

  1. *void prf(int i, int &(*a)) { a_[19][9] = 19; }
    what do you wish this procedure to return?
    \
  2. You talk of nested parallelism. Are you using OpenMP
    or something else?
    \
  3. One thing I can answer - we do not have a -fpermissive switch.


    #include<stdio.h>
    #include<stdlib.h>

    /*void prf(int i, int &(a)) {
    a[19][9] = 19;
    }
    /

    int main(void) {
    int x = 30, y = 20, z = 10;

    int (*a)[y][z];
    a = malloc(x * sizeof * a);

    for (int i = 0; i < x; i++) {
    //prf(i, a);
    a[5][9] = 5;
    printf("%d %d %d\n", i, a[5][9], a[19][9]);
    }

    free(a);
    return 0;
    }

    dave_

SUBJECT CLOSED

I want array will return from function with value 19 in all elements of y dimensions.

this is working with typically dynamic 3D decalaration (new lines are marked with ////) but to take care of multiD array in openacc is terrible

in stack overflow i have simplified the code even more

#include<stdio.h>
#include<stdlib.h>

void prf(int i, int *** &a) {
a_[19][9] = 19;
}

int main(void) {
int x = 30, y = 20, z = 10;

//int (*a)[y][z] = 0;
//a = malloc(x * sizeof * a);

int ***a;

a = (int ***) malloc(x * sizeof(int **)); ////
for (int j = 0; j < x; j++) { ////
a[j] = (int **) malloc(y * sizeof(int *)); ////
for (int i = 0; i < y; i++) ////
a[j] = (int *) calloc(z, sizeof(int)); ////
} ////

for (int i = 0; i < x; i++) {
prf(i, a);
a[5][9] = 5;
printf("%d %d %d\n", i, a[5][9], a[19][9]);
}

for (int j = 0; j < x; j++) { ////
for (int i = 0; i < y; i++) { ////
free(a[j]); } ////
free(a[j]); } ////

free(a);
return 0;
}

it looks that -fpermissive is accepted on main but the function is rejecting it

about nested loops, I want to use openacc and it looks that pgi supports then but not gcc



ps I gave up trying this kind of array, it looks that i am not conforming some c standards which gcc passed with -fpermissive

http://c-faq.com/aryptr/ary2dfunc3.html


SUBJECT CLOSED_