public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/58482] New: gomp4: user defined reduction produce wrong result
@ 2013-09-20 10:52 vincenzo.innocente at cern dot ch
  2013-09-20 11:16 ` [Bug libgomp/58482] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2013-09-20 10:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58482

            Bug ID: 58482
           Summary: gomp4: user defined reduction produce wrong result
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch
                CC: jakub at gcc dot gnu.org

I acknowledge  that my understanding of "omp declare" is still limited.
Still the example below produces different result with and w/o -fopenmp

gcc version 4.9.0 20130919 (experimental) [gomp-4_0-branch revision 202766]
(GCC) 
pb-d-128-141-131-94:vectorize innocent$ c++ -std=c++11  ured_omp4.cpp -O
-ftree-vectorizer-verbose=1; ./a.out
523776,-523776
pb-d-128-141-131-94:vectorize innocent$ c++ -std=c++11  ured_omp4.cpp -O
-ftree-vectorizer-verbose=1 -fopenmp; ./a.out
ured_omp4.cpp:26:8: note: loop turned into non-loop; it never loops
ured_omp4.cpp:26:8: note: loop turned into non-loop; it never loops
523776,523776


cat ured_omp4.cpp
#define Type float

struct TwoInt {
  Type a=0;
  Type b=0;

#pragma omp declare simd
  TwoInt & operator+=(TwoInt rh) {
    a+=rh.a;
    b-=rh.b;
  }

#pragma omp declare simd
  TwoInt & add(TwoInt rh) {
    a+=rh.a;
    b-=rh.b;
    return *this;
  }


};

#pragma omp declare reduction (foo:struct TwoInt: omp_out.add(omp_in))


TwoInt sum(Type const * q, int NN) {
  TwoInt s;
#pragma omp simd reduction(foo:s)
  for (int i=0;i<NN;++i) {
    TwoInt l; l.a=q[i]; l.b = q[i];
    s.add(l);
  }
  return s;
}

#include<iostream>
int main() {
  constexpr int NN=1024;
  Type q[NN];
  Type a=0;
  for (auto & e: q) e=a++;

  auto s = sum(q,NN);
  std::cout << s.a << "," << s.b << std::endl;


  return 0;
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-26  7:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-20 10:52 [Bug libgomp/58482] New: gomp4: user defined reduction produce wrong result vincenzo.innocente at cern dot ch
2013-09-20 11:16 ` [Bug libgomp/58482] " jakub at gcc dot gnu.org
2013-09-20 13:28 ` jakub at gcc dot gnu.org
2013-09-21 15:47 ` vincenzo.innocente at cern dot ch
2013-09-21 19:04 ` jakub at gcc dot gnu.org
2013-09-26  7:58 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).