Hi,

You could solve this by specializing the code according to the version of the 
OpenMP specification supported:

#if _OPENMP >= 201511
// OpenMP 4.5 and newer
#else
// features up to OpenMP 3.1
#endif

It’s more work in the compiler, but the auto-generated code does not have to be 
pretty. ☺

Kind regards,
        -michael

From: cython-devel 
[mailto:cython-devel-bounces+michael.klemm=intel....@python.org] On Behalf Of 
Nathan Goldbaum
Sent: Friday, August 31, 2018 4:51 PM
To: Core developer mailing list of the Cython compiler <cython-devel@python.org>
Subject: [Cython] OpenMP 4.5 array reductions

Hi all,

I'm curious if there would be any interest in adding support for OpenMP 4.5 
array reduction in the cython compiler or alternatively detecting these cases 
and raising a cython compiler error.

Currently cython is generating code that will compile but might lead to race 
conditions. See:

https://github.com/cython/cython/issues/2316
https://github.com/cython/cython/issues/1504

The trouble with fixing this in the cython compiler is that adding the 
appropriate OpenMP pragmas might generate code that will no longer compile on 
compilers that don't support OpenMP 4.5. However perhaps that's a better 
alternative than the status quo, which is generating code that might produce 
random results.

I'd very much appreciate any feedback or advice here as this is currently 
blocking our ability to easily add OpenMP to our cython code in places where 
we'd like threads to do parallel reductions on large arrays. I would also not 
be surprised if there is code in the wild that is racy and silently producing 
incorrect results.

-Nathan
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to