Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ICE] Propagate_necessity for stream refs #9

Open
IgWod opened this issue Jun 8, 2020 · 1 comment
Open

[ICE] Propagate_necessity for stream refs #9

IgWod opened this issue Jun 8, 2020 · 1 comment
Assignees
Labels
bug Something isn't working compiler Compiler related issue

Comments

@IgWod
Copy link

IgWod commented Jun 8, 2020

The following program fails to compile with an internal compiler error:

#include <stdio.h>
#include <stdlib.h>
#include "../common/common.h"
#include "../common/sync.h"

int main()
{
  double sleft[2] __attribute__((stream));
  void* sleft_ref = malloc(2*sizeof(void*));
  memcpy(sleft_ref, sleft, 2*sizeof(void*));

  double scenter[2] __attribute__((stream));
  void* scenter_ref = malloc(2*sizeof(void*));
  memcpy(scenter_ref, scenter, 2*sizeof(void*));

  double sright[2] __attribute__((stream));
  void* sright_ref = malloc(2*sizeof(void*));
  memcpy(sright_ref, sright, 2*sizeof(void*));

  double input[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
  double* input_ref = input;

  double output[12];
  double* output_ref = output;

  for(int id = 0; id < 2; id++)
  {
    double left_out[1];
    double center_out[5];
    double right_out[1];

    #pragma omp task output(sleft_ref[id] << left_out[1], \
                            scenter_ref[id] << center_out[5], \
                            sright_ref[id] << right_out[1])
    {
      left_out[0] = input_ref[id * 5];
      for(int i = 0; i < 5; i++)
        center_out[i] = input_ref[id * 5 + i + 1];
      right_out[0] = input_ref[id * 5 + 6];
    }
  }

  for(int id = 0; id < 2; id++)
  {
    double left_in[1];
    double center_in[5];
    double right_in[1];

    #pragma omp task input(sleft_ref[id] >> left_in[1], \
                           scenter_ref[id] >> center_in[5], \
                           sright_ref[id] >> right_in[1])
    {
      output_ref[id * 5 + 1] = (left_in[0] + center_in[0] + center_in[1]) / 3.0;
      for(int i = 1; i < 4; i++)
        output_ref[id * 5 + i + 1] = (center_in[i - 1] + center_in[i] + center_in[i + 1]) / 3.0;
      output_ref[id * 5 + 5] = (right_in[0] + center_in[3] + center_in[4]) / 3.0;
    }
  }

  #pragma omp taskwait

  for(int i = 0; i < 10; i++)
    printf("%lf ", output[i + 1]);
  printf("\n");
}

The following error is generated:

during GIMPLE pass: cddce
stream_simple.c:69:1: internal compiler error: in propagate_necessity, at tree-ssa-dce.c:902
   69 | }
      | ^
0xb648ce propagate_necessity
        ../../gcc/tree-ssa-dce.c:902
0xb648ce perform_tree_ssa_dce
        ../../gcc/tree-ssa-dce.c:1592

The problem does not appear when stream references are declared outside the main function:

void* sleft_ref;
void* scenter_ref;
void* sright_ref;

int main()
{
  double sleft[2] __attribute__((stream));
  sleft_ref = malloc(2*sizeof(void*));
  memcpy(sleft_ref, sleft, 2*sizeof(void*));

  double scenter[2] __attribute__((stream));
  scenter_ref = malloc(2*sizeof(void*));
  memcpy(scenter_ref, scenter, 2*sizeof(void*));

  double sright[2] __attribute__((stream));
  sright_ref = malloc(2*sizeof(void*));
  memcpy(sright_ref, sright, 2*sizeof(void*));
@IgWod IgWod added bug Something isn't working compiler Compiler related issue labels Jun 8, 2020
@IgWod IgWod changed the title Internal compiler error: in propagate_necessity Internal compiler error in propagate_necessity for stream refs Jun 8, 2020
@nmnobre nmnobre changed the title Internal compiler error in propagate_necessity for stream refs [ICE] Propagate_necessity for stream refs Jun 11, 2020
@nmnobre
Copy link
Member

nmnobre commented Jun 11, 2020

If compiled with -fno-tree-dce, you get an extra gift: a beautiful, chocolate-glazed segmentation fault 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Compiler related issue
Projects
None yet
Development

No branches or pull requests

3 participants