[Bug c/68960] New: __attribute__ ((aligned ())) is ignored for OpenMP private variables

dxin at usc dot edu gcc-bugzilla@gcc.gnu.org
Thu Dec 17 15:40:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68960

            Bug ID: 68960
           Summary: __attribute__ ((aligned ())) is ignored for OpenMP
                    private variables
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dxin at usc dot edu
  Target Milestone: ---

Test code:

    #include <stdio.h>
    int main(void) 
    {
        int temp[4][4] __attribute__ ((aligned (256)))={{0}};
        //#pragma omp for private(temp)
        for(size_t i=0; i<4;i++){
            printf("chunk %zu: &temp[0][0]=%p\n", i, &temp[0][0]);
        }
        return 0;
    }

Without OpenMP, alignment is correctly set to 256 bytes:
    gcc main.c -fopenmp -std=gnu11
    ./a.out
    chunk 0: &temp[0][0]=0x7ffffbe0ef00 
    chunk 1: &temp[0][0]=0x7ffffbe0ef00
    chunk 2: &temp[0][0]=0x7ffffbe0ef00
    chunk 3: &temp[0][0]=0x7ffffbe0ef00

With OpenMP, alignment is default 16 bytes:
    gcc main.c -fopenmp -std=gnu11
    ./a.out 
    chunk 0: &temp[0][0]=0x7fff16c56ac0
    chunk 1: &temp[0][0]=0x7fff16c56ac0
    chunk 2: &temp[0][0]=0x7fff16c56ac0
    chunk 3: &temp[0][0]=0x7fff16c56ac0


Tested with:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4,          on x86-64
gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04) 4.8.4,   on arm v7


More information about the Gcc-bugs mailing list