Skip to content

error: OpenMP array shaping operation is not allowed here #34

Open

Description

@jinz2014

I tried amdclang to compile the program array_shaping.1.c, and got the error message

array_shaping.1.c:28:39: error: OpenMP array shaping operation is not allowed here
28 | #pragma omp target update from( (([nx][ny+2])a)[0:nx][1],
| ^
array_shaping.1.c:29:39: error: OpenMP array shaping operation is not allowed here
29 | (([nx][ny+2])a)[0:nx][ny] )
| ^

Can you suggest which compilers and options for the program ?

Activity

  1. milfeld commented on Sep 10, 2025

    @milfeld
    Contributor

    In godbolt.org I checked nvc++ 25.7 and gcc 15.2 and they appear not to have implemented this feature yet, they didn't understand the shaping syntax.

    nvc++ -fopenmp -mp=gpu *.cpp
    v25.7  NOT compiled
    "<source>", line 27: error: invalid text in pragma
        #pragma omp target update from( (([Nx][Ny+2])a)[0:Nx][1],   (([Nx][Ny+2])a)[0:Nx][ny] )
                                        ^

    I have replicated the problem. The x86-64 clang++ compilers 14->21 complained that it is "not allowed here" for the example, which is modeled after the use case: updating discontiguous elements for a target region. I have created a ticket in the examples-internal repo to discuss this issue.

    $ clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda snip.cpp
    snip.cpp:29:37: error: OpenMP array shaping operation is not allowed here
       29 |     #pragma omp target update from( (([Nx][Ny+2])a)[0:Nx][1],   (([Nx][Ny+2])a)[0:Nx][Ny] )
          |                                     ^

    I have been using this test code as a quick test:

    #include <stdio.h>
    #include <stdlib.h>
    #include <omp.h>
    #include <string.h>
    
    #define Nx 4
    #define Ny 4
    
    #pragma begin target declare
    void change_ghost(int *a, int nx, int ny){
      for(int i=0; i<nx; i++){
        a[i*(ny+2)+1]  += 2;
        a[i*(ny+2)+ny] += 2;
      }
    }
    #pragma end target declare
    
    int main(){
      int *a;
      a = (int*)malloc(sizeof(int)*Nx*(Ny+2));
      memset(a, 0,     sizeof(int)*Nx*(Ny+2));
      #pragma omp target data map( a[0:Nx*(Ny+2)] )
      {
        #pragma omp target
        change_ghost(a,Nx,Ny);
    
    //  #pragma omp target update from( a[0:Nx*(Ny+2)] )
    //  #pragma omp target update from( ([Nx][Ny+2])a )
        #pragma omp target update from( (([Nx][Ny+2])a)[0:Nx][1],   (([Nx][Ny+2])a)[0:Nx][Ny] )
    //  #pragma omp target update from( (([Nx][Ny+2])a)[0:Nx][1:1], (([Nx][Ny+2])a)[0:Nx][Ny:1] )
        
        printf(" a[1], a[Ny] =  %d %d\n", a[1],a[Ny]);
      }
      printf(" a[1], a[Ny] =  %d %d\n", a[1],a[Ny]);
      return 0;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions