* Willing to contribute to the project Idea "Fortran – DO CONCURRENT" @ 2023-02-23 13:15 varma datla 2023-02-23 15:07 ` Tobias Burnus 0 siblings, 1 reply; 5+ messages in thread From: varma datla @ 2023-02-23 13:15 UTC (permalink / raw) To: fortran [-- Attachment #1: Type: text/plain, Size: 306 bytes --] Hi, My name is Satyanarayana Varma. I am willing to contribute to the project idea "Fortran – DO CONCURRENT". Please suggest some resources to me so that I can learn your technologies. Could you please assign me some good first issues for the starting. Thank you, Regards. Satyanarayana Datla ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Willing to contribute to the project Idea "Fortran – DO CONCURRENT" 2023-02-23 13:15 Willing to contribute to the project Idea "Fortran – DO CONCURRENT" varma datla @ 2023-02-23 15:07 ` Tobias Burnus 2023-02-23 15:24 ` Damian Rouson 0 siblings, 1 reply; 5+ messages in thread From: Tobias Burnus @ 2023-02-23 15:07 UTC (permalink / raw) To: varma datla; +Cc: fortran, gcc-patches Hi, and welcome to the GCC / gfortran community. On 23.02.23 14:15, varma datla via Fortran wrote: > I am willing to contribute to the project idea "Fortran – DO CONCURRENT". I hope the following helps a bit – it is admittedly a bit chaotic, but I try to write something cleaner later. But to have something to think of and to startwith, it should be sufficient: I think there are two parts to it: First, to add the changes of newer Fortran to gfortran and then to actually use them to generate concurrently running code. (Internally, gfortran currently handles 'do concurrent' to run mostly like a normal loop – except that it annotates the loops are independent. – Real parallelization would be useful, however.) If you want to see examples, see do_concurrent_1.f90 to do_concurrent_6.f90 in gfortran's testsuite, i.e. gcc/testsuite/gfortran.dg/ in the GCC sources. That's at https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/testsuite/gfortran.dg;hb=refs/heads/master / But it is best to download GCC yourself via Git as described at https://gcc.gnu.org/git.html I want to note that the DO CONCURRENT syntax also permits a mask argument, like in 'do concurrent (i=1:5, j=1:5, (i/=j))' where the last argument selects a subset. For the Fortran standard, see https://gcc.gnu.org/wiki/GFortranStandards Fortran 2018 (= 18-007r1) adds for locality specifiers: LOCAL, LOCAL_INIT, SHARED and DEFAULT(NONE). Fortran 202x alias 2023 adds 'reduce' as in 'do concurrent (i = 1, n) reduce(+:a, b, c) reduce(max:d, e, f)' I think the first step is to add parsing support for those new features, i.e. store them, check for issues (diagnostic) and then fail with a 'sorry not yet implemented'. The next step would be to implement LOCAL/LOCAL_INIT for running on the host. And then, finally, would be to translate into code which can then be run concurrently. I was thinking of mapping it internally to OpenMP or OpenACC, to be toggled via a commandline option like -fdo-concurrent=<openmp,openmp-target,openacc,...>. * * * I think the first step would be to download GCC and build it. Something like "git clone" as described above, then "mkdir build" (some directory); "cd build" and then "../configure --prefix=where-to-install" followed by "make -j12" and "make install". The "-j12" runs 12 build jobs in parallel. How much to use depends on your system. You probably need to install some development versions of libraries such as ISL, gmp, mpfr and mpc. If you don't have them readily, an option is to run ./contrib/download_prerequisites to download those and build them automatically alongside GCC. So far for now. If you have questions, please ask. — And I will try to write something more structured later. Tobias -- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Willing to contribute to the project Idea "Fortran – DO CONCURRENT" 2023-02-23 15:07 ` Tobias Burnus @ 2023-02-23 15:24 ` Damian Rouson 2023-02-23 15:56 ` Tobias Burnus 2023-02-23 16:20 ` Steve Kargl 0 siblings, 2 replies; 5+ messages in thread From: Damian Rouson @ 2023-02-23 15:24 UTC (permalink / raw) To: Tobias Burnus; +Cc: fortran, gcc-patches, varma datla [-- Attachment #1: Type: text/plain, Size: 4065 bytes --] I wonder if a relatively easy starting point would be enabling the declaration of do concurrent construct variables: do concurrent (integer :: i = 1:n) It’s a minor convenience and less exciting than adding locality specifiers but possibly a good first exercise. Damian On Thu, Feb 23, 2023 at 07:08 Tobias Burnus <tobias@codesourcery.com> wrote: > Hi, > > and welcome to the GCC / gfortran community. > > On 23.02.23 14:15, varma datla via Fortran wrote: > > I am willing to contribute to the project idea "Fortran – DO CONCURRENT". > > I hope the following helps a bit – it is admittedly a bit chaotic, but I > try to write something cleaner later. > > But to have something to think of and to startwith, it should be > sufficient: > > I think there are two parts to it: First, to add the changes of newer > Fortran to gfortran and then to actually use them to generate > concurrently running code. (Internally, gfortran currently handles 'do > concurrent' to run mostly like a normal loop – except that it annotates > the loops are independent. – Real parallelization would be useful, > however.) > > If you want to see examples, see do_concurrent_1.f90 to > do_concurrent_6.f90 in gfortran's testsuite, i.e. > gcc/testsuite/gfortran.dg/ in the GCC sources. That's at > > https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/testsuite/gfortran.dg;hb=refs/heads/master > / But it is best to download GCC yourself via Git as described at > https://gcc.gnu.org/git.html > > I want to note that the DO CONCURRENT syntax also permits a mask > argument, like in 'do concurrent (i=1:5, j=1:5, (i/=j))' where the last > argument selects a subset. > > For the Fortran standard, see https://gcc.gnu.org/wiki/GFortranStandards > > Fortran 2018 (= 18-007r1) adds for locality specifiers: LOCAL, > LOCAL_INIT, SHARED and DEFAULT(NONE). > > Fortran 202x alias 2023 adds 'reduce' as in 'do concurrent (i = 1, n) > reduce(+:a, b, c) reduce(max:d, e, f)' > > I think the first step is to add parsing support for those new features, > i.e. store them, check for issues (diagnostic) and then fail with a > 'sorry not yet implemented'. > > The next step would be to implement LOCAL/LOCAL_INIT for running on the > host. > > And then, finally, would be to translate into code which can then be run > concurrently. I was thinking of mapping it internally to OpenMP or > OpenACC, to be toggled via a commandline option like > -fdo-concurrent=<openmp,openmp-target,openacc,...>. > > * * * > > I think the first step would be to download GCC and build it. Something > like "git clone" as described above, then "mkdir build" (some > directory); "cd build" and then "../configure --prefix=where-to-install" > followed by "make -j12" and "make install". The "-j12" runs 12 build > jobs in parallel. How much to use depends on your system. > > You probably need to install some development versions of libraries such > as ISL, gmp, mpfr and mpc. If you don't have them readily, an option is > to run ./contrib/download_prerequisites to download those and build them > automatically alongside GCC. > > So far for now. If you have questions, please ask. — And I will try to > write something more structured later. > > Tobias > > -- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, > 80634 Münch > <https://www.google.com/maps/search/:+Arnulfstra%C3%9Fe+201,+80634+M%C3%BCnch?entry=gmail&source=g>en; > Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, > Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB > 106955 > > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, > 80634 Münch > <https://www.google.com/maps/search/:+Arnulfstra%C3%9Fe+201,+80634+M%C3%BCnch?entry=gmail&source=g>en; > Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, > Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB > 106955 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Willing to contribute to the project Idea "Fortran – DO CONCURRENT" 2023-02-23 15:24 ` Damian Rouson @ 2023-02-23 15:56 ` Tobias Burnus 2023-02-23 16:20 ` Steve Kargl 1 sibling, 0 replies; 5+ messages in thread From: Tobias Burnus @ 2023-02-23 15:56 UTC (permalink / raw) To: Damian Rouson; +Cc: fortran, varma datla (I have now also left out the gcc* mailing list, leaving only fortran@gcc.gnu.org in.) On 23.02.23 16:24, Damian Rouson wrote: > I wonder if a relatively easy starting point would be enabling the > declaration of do concurrent construct variables: > > do concurrent (integer :: i = 1:n) > > It’s a minor convenience and less exciting than adding locality > specifiers but possibly a good first exercise. I concur that this is a useful Fortran 2018 feature. But this creates a new scope which is also not that straight forward. Thus, maybe rather something for a third instead of for the first exercise :-) But in any case, another F2018 omission – and good that you spotted the omission. * * * Regarding building GCC: If you build as mentioned in my previous email, GCC is bootstrapped. That is: It is build first with the system compiler (likely some older GCC), then the just build compiler is used to build GCC again (without debugging symbols), then that one is used to build GCC a third time (with debugging symbols) — and then there is a check whether the generated in Stage 3 with debugging symbols stripped is identical to the one in Stage 2. If you develop, a faster way is to build with: --disable-bootstrap --disable-multilib --disable-libstdcxx-pch * The first one disables the three-stage build process and builds only with the system compiler. (Caveat: This one might have different warnings. Thus, when a patch is ready, a bootstrap build is required to avoid surprises with warnings treated as errors.) * The second one disables 32bit support, which is usually build alongside 64bit support on Linux. * PCH are C++ pre-compiled headers. Those take some time to build and also slows building down. Running the GCC testsuite: "make check-fortran -j12" in the main build directory tests everything Fortran related (libgomp/testsuite/ and gcc/testsuite/*fortran*/.) – To check for a specific testcase in the latter, do "cd gcc" in the build directory and run 'make check-fortran RUNTESTFLAGS="dg.exp=myTest*.f90"' where dg.exp is the file in the gfortran.dg/ directory and myTest*.f90 matches the file name. What is done with the tests is determined by '{ dg-... }' in the comment lines, in particular 'dg-do run/compile' tells whether it is a run-time or compile-time check. And 'dg-error'/'dg-warning' check for the presence of diagnostic lines. * * * I think I stop here. — If you have questions or something is unclear or does not work, please tell. Tobias PS: For the greater picture, in particular Nvidia did some experiments with running do concurrent really concurrently (with offloading to their accelerators). See for instance: https://developer.nvidia.com/blog/using-fortran-standard-parallel-programming-for-gpu-acceleration/ and https://developer.nvidia.com/blog/accelerating-fortran-do-concurrent-with-gpus-and-the-nvidia-hpc-sdk/ That's unsurprisingly a bit Nvidia centric, but it should give an idea how concurrency handling could look like. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Willing to contribute to the project Idea "Fortran – DO CONCURRENT" 2023-02-23 15:24 ` Damian Rouson 2023-02-23 15:56 ` Tobias Burnus @ 2023-02-23 16:20 ` Steve Kargl 1 sibling, 0 replies; 5+ messages in thread From: Steve Kargl @ 2023-02-23 16:20 UTC (permalink / raw) To: Damian Rouson; +Cc: Tobias Burnus, fortran, gcc-patches, varma datla On Thu, Feb 23, 2023 at 07:24:26AM -0800, Damian Rouson wrote: > I wonder if a relatively easy starting point would be enabling the > declaration of do concurrent construct variables: > > do concurrent (integer :: i = 1:n) > > It’s a minor convenience and less exciting than adding locality specifiers > but possibly a good first exercise. > > > Damian I've already implemented 95% of the above. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96255 Unfortunately, the last 5% will take me too much time, which I don't have at the moment. Problems arise from the parsing of an iterator is shared by do current, forall, implied-do, and good old do-loops. For the first 3, 'i' is a control variable and is a statement entity (i.e., in the namespace of construct). To do a type spec in one of these cleanly, it would be prudent to either define a namespace for the construct or to use a shadow variable. The shadow variablei, which I was leaning towards, would replace the above with something like do concurrent (integer :: _i = 1:n) '_i' cannot conflict 'i', but this requires walking the execution block of the construct and replacing 'i' with '_i'. Perhaps, starting with the patch in PR96255 would be gentle intro to gfortran hacking. -- Steve ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-23 16:20 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-02-23 13:15 Willing to contribute to the project Idea "Fortran – DO CONCURRENT" varma datla 2023-02-23 15:07 ` Tobias Burnus 2023-02-23 15:24 ` Damian Rouson 2023-02-23 15:56 ` Tobias Burnus 2023-02-23 16:20 ` Steve Kargl
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).