From stefan_ml at behnel.de Fri Jul 15 03:45:37 2022 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 15 Jul 2022 09:45:37 +0200 Subject: [Cython] Nested prange loops - (was: [cython-users] Converting to Python objects with nogil (inside prange for loop)) In-Reply-To: References: Message-ID: <6d788696-0dcc-49e0-b20d-8cfa54c97b19@behnel.de> Hi, nested prange loops seem to be a common gotcha for users. I can't say if there is ever a reason to do this, but at least I can't think of any. For me, this sounds like we should turn it into a compile time error ? unless someone can think of a use case? Even in that case, I'd still emit a warning since it seems so unlikely to be intended. Please reply to the cython-users list to facilitate user feedback. Stefan -------- Forwarded Message -------- Subject: Re: [cython-users] Converting to Python objects with nogil (inside prange for loop) Date: Fri, 15 Jul 2022 07:43:26 +0100 > with nogil, parallel(): > ? for i in prange(N): > ? ? for j in prange(km.BatchSize): You usually only want one loop in a set of nested loops to be prange. Typically the outer loop, but in this case it might be easier to parallelize the inner loop. From dalcinl at gmail.com Mon Jul 18 06:58:10 2022 From: dalcinl at gmail.com (Lisandro Dalcin) Date: Mon, 18 Jul 2022 13:58:10 +0300 Subject: [Cython] Nested prange loops - (was: [cython-users] Converting to Python objects with nogil (inside prange for loop)) In-Reply-To: <6d788696-0dcc-49e0-b20d-8cfa54c97b19@behnel.de> References: <6d788696-0dcc-49e0-b20d-8cfa54c97b19@behnel.de> Message-ID: On Fri, 15 Jul 2022 at 11:03, Stefan Behnel wrote: > nested prange loops seem to be a common gotcha for users. I can't say if > there is ever a reason to do this, but at least I can't think of any. Unless you make nested prange() emit the following C code: #pragma omp parallel for collapse(2) for (int i = 0; i < M; ++i) { for (int j = 0; j < N; ++j) { // do something } } This is a very valid use case, as users should not care whether which of M or N (or both) are large enough to split across available threads, thus leading to thread subutilization. And the nice thing about it is that the Cython implementation is probably trivial, just adding a `collapse(N)` clause in the outermost `#pragma omp for`. But of course, there would be nasty details to address, like what to do if the start of the inner "j" index depends on the outer "i" index (i.e a triangular loop), or `break` or `continue` statements are used. For reference, here you have a summary of the rules: https://www.ibm.com/docs/en/xl-fortran-linux/16.1.1?topic=clauses-collapse For > me, this sounds like we should turn it into a compile time error ? unless > someone can think of a use case? Well, I just gave you one, but if you want to add checks for bad usage and corner cases, the burden put on Cython development may be too high. I would just blindly transform nested prange() calls to a `collapse(N)` clause in the outermost `#pragma omp for` loop, and either let the C compiler complain about the user code breaking the rules, or let users pay for the consequences of breaking the Open MP rules with undefined behavior. -- Lisandro Dalcin ============ Senior Research Scientist Extreme Computing Research Center (ECRC) King Abdullah University of Science and Technology (KAUST) http://ecrc.kaust.edu.sa/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Sun Jul 31 05:15:47 2022 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 31 Jul 2022 11:15:47 +0200 Subject: [Cython] Welcome David Woods as a Cython core developer Message-ID: <45672834-0f7a-8134-af23-d7c396038ee1@behnel.de> Hi everyone, with the release of the first 3.0 alpha that supports Python 3.11 (aptly named "alpha 11"), I'm happy to announce that David Woods has been promoted to a Cython core developer. David has shown an extraordinary commitment and dedication over the last years. His first merged commits were already back in 2015, mostly related to the C++ support. But within the last two years, he voluntarily took over more and more responsibility for bugs and issues and developed several major new features for the project. This includes the Walrus operator (PEP 572), cdef dataclasses (modelled after PEP 557), internal "std::move()" usage in C++ mode or support for Unicode identifiers and module names, all of which form a major part of the 3.0 feature set. David has more than deserved a place in the circle of present and prior core devs. David, thank you for your impressive work on Cython, and welcome to the core team! Stefan From dw-git at d-woods.co.uk Sun Jul 31 14:51:29 2022 From: dw-git at d-woods.co.uk (da-woods) Date: Sun, 31 Jul 2022 19:51:29 +0100 Subject: [Cython] Welcome David Woods as a Cython core developer In-Reply-To: <45672834-0f7a-8134-af23-d7c396038ee1@behnel.de> References: <45672834-0f7a-8134-af23-d7c396038ee1@behnel.de> Message-ID: <38bd8889-8f78-535b-5e88-0f23c0470f18@d-woods.co.uk> Hi, I'm not sure if it's necessary to for me to reply to this, but: thanks. Hopefully some of the features will be (or already have been) useful to people. David On 31/07/2022 10:15, Stefan Behnel wrote: > Hi everyone, > > with the release of the first 3.0 alpha that supports Python 3.11 > (aptly named "alpha 11"), I'm happy to announce that David Woods has > been promoted to a Cython core developer. > > David has shown an extraordinary commitment and dedication over the > last years. His first merged commits were already back in 2015, mostly > related to the C++ support. But within the last two years, he > voluntarily took over more and more responsibility for bugs and issues > and developed several major new features for the project. This > includes the Walrus operator (PEP 572), cdef dataclasses (modelled > after PEP 557), internal "std::move()" usage in C++ mode or support > for Unicode identifiers and module names, all of which form a major > part of the 3.0 feature set. David has more than deserved a place in > the circle of present and prior core devs. > > David, thank you for your impressive work on Cython, > and welcome to the core team! > > Stefan > _______________________________________________ > cython-devel mailing list > cython-devel at python.org > https://mail.python.org/mailman/listinfo/cython-devel From matti.picus at gmail.com Sun Jul 31 15:47:04 2022 From: matti.picus at gmail.com (Matti Picus) Date: Sun, 31 Jul 2022 22:47:04 +0300 Subject: [Cython] Welcome David Woods as a Cython core developer In-Reply-To: <45672834-0f7a-8134-af23-d7c396038ee1@behnel.de> References: <45672834-0f7a-8134-af23-d7c396038ee1@behnel.de> Message-ID: <8224cc50-c771-09ed-842a-bd0b850ab08b@gmail.com> As someone watching from the sidelines, it is nice to see the Cython team grow, especially with such a talented and committed contributor. Matti On 31/7/22 12:15, Stefan Behnel wrote: > Hi everyone, > > with the release of the first 3.0 alpha that supports Python 3.11 > (aptly named "alpha 11"), I'm happy to announce that David Woods has > been promoted to a Cython core developer. > > David has shown an extraordinary commitment and dedication over the > last years. His first merged commits were already back in 2015, mostly > related to the C++ support. But within the last two years, he > voluntarily took over more and more responsibility for bugs and issues > and developed several major new features for the project. This > includes the Walrus operator (PEP 572), cdef dataclasses (modelled > after PEP 557), internal "std::move()" usage in C++ mode or support > for Unicode identifiers and module names, all of which form a major > part of the 3.0 feature set. David has more than deserved a place in > the circle of present and prior core devs. > > David, thank you for your impressive work on Cython, > and welcome to the core team! > > Stefan > _______________________________________________ > cython-devel mailing list > cython-devel at python.org > https://mail.python.org/mailman/listinfo/cython-devel