Portal:Perl+OpenMP
Introduction[edit | edit source]
WIth most perl binaries compiled with a version of GCC that supports OpenMP in some form, it make a lot of sense to explore the use of OpenMP with Perl programs - and to make it much easier. This is where the Perl+OpenMP Project comes into play. The following page is really meant to be an overview of what is possible and the resources available to those interested in such efforts.
See Also[edit | edit source]
See main project site, https://github.com/Perl-OpenMP/ for more information.
Quick Start[edit | edit source]
#!/usr/bin/env perl use strict; use warnings; use OpenMP; use Inline ( C => 'DATA', with => qw/OpenMP::Simple/, ); my $omp = OpenMP->new; for my $want_num_threads ( 1 .. 8 ) { $omp->env->omp_num_threads($want_num_threads); $omp->env->assert_omp_environment; # (optional) validates %ENV # call parallelized C function my $got_num_threads = _check_num_threads(); printf "%0d threads spawned in ". "the OpenMP runtime, expecting %0d\n", $got_num_threads, $want_num_threads; } __DATA__ __C__ /* C function parallelized with OpenMP */ int _check_num_threads() { int ret = 0; PerlOMP_GETENV_BASIC #pragma omp parallel { #pragma omp single ret = omp_get_num_threads(); } return ret; } __END__
Alternate Compiler Support[edit | edit source]
This section will cover using Perl+OpenMP on compilers other than GCC. The trick is to adapt `Alien::OpenMP` to support other compilers that can be used to compile `perl` and also support OpenMP.
Clang[edit | edit source]
In principle, `Alien::OpenMP` supports clang.
Intel OneAPI[edit | edit source]
section in progress ... (track at https://github.com/Perl-OpenMP/p5-Alien-OpenMP/issues/25)
Special Topics[edit | edit source]
Perl+OpenMP and wxPerl[edit | edit source]
See https://github.com/Perl-OpenMP/p5-OpenMP-wxPerl for a demo.

Intel Xeon Phi Co-Processor[edit | edit source]
section in process ...(track https://github.com/Perl-OpenMP/p5-Alien-OpenMP/issues/26)