cdarke has asked for the wisdom of the Perl Monks concerning the following question:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: OpenMP from Perl?
by Moron (Curate) on Jun 21, 2007 at 12:45 UTC | |
I know absolutely nothing about OpenMP (update: but Google is my friend - it already tells me that ANSI C is enough, so already the water got warmer). It appears that OpenMP is dissembled across embedded, environment variable and shared object facilities. To use Perl instead of C for all three of these requires then three separate techniques: 1) compiler directives: For this part of the interface you could translate Perl main programs to C main programs without knowledge of C using B::C (update: or perlcc) and then apply the OpenMP directives to that as directed by the OpenMP documentation. 2) Environment variables: For these, I tend to make a subroutine that gets them parametrically and then uses IPC::Open3 to create a session with whatever foreign program (could be your own C from Perl program in thes case) is being run with syntax something like: (update: strictly speaking that is a translation technique of shell to Perl rather than C to Perl of course) 3) shared objects - load those into Perl using P5NCI::Library. That at least completes the 3 requirements to build the interfacing I found by googling - if there are more, do tell and we'll have a look for you. But (update) to address more of your questions: "Is Perl 5 multi-threading robust enough to take such a standard?" Nothing to do with robustness - the OpenMP standard is suitable for C. You could try to take Perl's multithreading at source level and interface that to OpenMP, but I suspect the water is too cold for you there. (Update: to be clear, for an OpenMP implementation you would have to achieve the multithreading via something like the three techniques I outline above, and not by using Perl's own multithreading) Will Perl 6 support OpenMP? I presume that the modules I have mentioned will get ported to Perl 6 so I presume yes insofar as you need to build your own main glue interfacing along lines such as above.
__________________________________________________________________________________
^M Free your mind! | [reply] [d/l] |
by cdarke (Prior) on Jun 21, 2007 at 13:31 UTC | |
Update: B::C must be still supported, since there is a 5.9.4 version, but I thought I read somewhere that it is going to be dropped? Maybe I was dreaming. | [reply] |
by Moron (Curate) on Jun 21, 2007 at 14:02 UTC | |
__________________________________________________________________________________
^M Free your mind!
| [reply] |
by Anonymous Monk on Jun 21, 2007 at 14:22 UTC | |
by Moron (Curate) on Jun 21, 2007 at 14:39 UTC | |
Re: OpenMP from Perl?
by BrowserUk (Patriarch) on Jun 21, 2007 at 14:24 UTC | |
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
by lin0 (Curate) on Jun 22, 2007 at 06:35 UTC | |
Hi BrowserUk, There is some work related to using OpenMP with piddles by Darin McGill, the author of PDL::Parallel::MPI. However, I am not aware of any concrete result yet. Cheers, lin0 | [reply] |
by BrowserUk (Patriarch) on Jun 22, 2007 at 08:10 UTC | |
Thanks lin0, that looks interesting. The MPI standard appears to be distributed processes controlled through function calls and 'sharing' data via tcp. Whilst distinctly non-trivial to implement, in Perl's terms, calling functions that fork processes and pass chunks of data back and forth via sockets is at least 'known technology'. There is some mention of threads in MPI-2, but they (seem) to relate to whether the programs using an MPI implementation can be threaded, and whether they can call the library routines from more than one thread serially or concurrently. Ie. The work is done by forking processes, but those processes might be multi-threaded. Looking at the OpenMP standard, it appears (at a fairly cursory reading) to use threads and shared memory to do the work. It also specifies that the spawning of threads and the subdivision and sharing of data be done via directives embedded in comments. The idea appears to be that by disabling the directives, the same program shoudl be able to run to completion as a single threaded application. And by enabling them, it completes, but more quickly--assuming the availability of multiple cpus/cores. The directives bit is easily, if controversially, achievable using a source filter. The most problematic part is that the API assumes an implicitly-shared memory environment--unlike Perl's iThreads which are explicitly-shared only. The problem is that the directives are geared to indicating to the preprocessor which variables need to be explicitly protected and/or later accumulated. In Perl's explicitly shared environment, that makes the information provided by the programmer on the directives almost the exact opposite of what is required. All of that said, as piddles are opaque objects at the perl level may mean that they can be implicitly shared by threads? Also, the fact that piddle slices can be referenced in-place may make the implementation of the parallel for directive easier than it is for perl arrays. I guess the real question is whether the PDL libraries are thread-safe? Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by lin0 (Curate) on Jun 22, 2007 at 13:33 UTC | |
Re: OpenMP from Perl?
by dcmertens (Scribe) on Jul 02, 2012 at 05:11 UTC | |
I know, I'm digging up an old post here, but for future reference the answer is, "Perl has supported MPI for many, many years." Search CPAN for Parallel::MPI and Parallel::MPI::Simple (I prefer the latter: much more perlish). In addition, the already mentioned PDL::Parallel::MPI is properly coded but has has a bad Makefile.PL. Fortunately, hand-tweaking the Makefile.PL to get it to work isn't hard at all if you know how to compile a C-based MPI program on your cluster. Now, I just wish I could get a hold of Darin so I could fix his Makefile.PL and get it passing tests again... | [reply] |
by etj (Priest) on May 23, 2022 at 20:11 UTC | |
There are plans https://github.com/PDLPorters/pdl/issues/349 to use OpenMP or a similar technology in PDL, though at the time of writing they are only plans. | [reply] [d/l] [select] |
Re: OpenMP from Perl?
by cdarke (Prior) on Jun 22, 2007 at 10:29 UTC | |
[reply] |