This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: autopar reduction and OMP_ATOMIC gimplify/expand changes - final patch

> You are planning to include _all_ that gimple code in a comment as an
> example of the transformation?  That's way too detailed and hard to
> follow.  It needs to be much more succinct.

I hoped to demonstrate the reduction code in all parts it is involved in.
I hope now it's clearer.
Still too long?

source code: 
  int sum=1;

  for (i = 0; i < N/1000; i++)
    x[i] = i + 3;

gimple-like code:

  # sum_29 = PHI <sum_11(5), 1(3)>
  # i_28 = PHI <i_12(5), 0(3)>
  D.1795_8 = i_28 + 3;
  x[i_28] = D.1795_8;
  sum_11 = D.1795_8 + sum_29;
  i_12 = i_28 + 1;
  if (N_6(D) > i_12)
    goto header_bb;


  # sum_21 = PHI <sum_11(4)>
  printf (&"%d"[0], sum_21);

after reduction transformation (only relevant parts):



  # Two new variables are created for each reduction:
  "reduction" is the variable holding the neutral element for the
  particular operation, e.g. 0 for PLUS_EXPR, 1 for MULT_EXPR, etc.
  "reduction_initial" is the initial value given by the user.
  It is kept and will be used after the parallel computing is done.  #

  reduction_initial.24_46 = 1;
  reduction.23_45 = 0;
  .paral_data_store.32.reduction.23 = reduction.23_45;
  #pragma omp parallel num_threads(4) 
  reduction.28_48 = .paral_data_load.33_51->reduction.23;

  #pragma omp for schedule(static)
  # sum.27_29 = PHI <sum.27_11, reduction.28_48>
  sum.27_11 = D.1827_8 + sum.27_29;

  # Adding this reduction phi is done at create_phi_for_local_result() #
  # reduction.23_58 = PHI <sum.27_11(5), 0(23)>
  # Creating the atomic operation is done at 
  create_call_for_reduction_1()  #

  #pragma omp atomic_load
  D.1839_59 = *&.paral_data_load.33_51->reduction.23;
  D.1840_60 = reduction.23_58 + D.1839_59;
  #pragma omp atomic_store (D.1840_60);
 # collecting the result after the join of the threads is done at
  a new variable "reduction_final" is created.  It calculates the final
  value from the initial value and the value computed by the threads #
  reduction_final.34_53 = .paral_data_load.33_52->reduction.23;
  sum_37 = reduction_initial.24_46 + reduction_final.34_53;
  sum_43 = D.1795_41 + sum_37;
  exit bb:
  # sum_21 = PHI <sum_43, sum_26>
  printf (&"%d"[0], sum_21);



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]