NAME

OpenMP - Metapackage for using OpenMP in Perl

SYNOPSIS

#!/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;
}

DESCRIPTION

Currently all this module does is eliminates a little boiler plate, but this also makes documentation and tutorials much more clear. It also makes it easier to install everything needed since this module will pull in OpenMP::Simple and OpenMP::Environment.

Installing this module will also install whichever of the following modules are not already on your system: OpenMP::Environment, OpenMP::Simple, Inline::C, and Alien::OpenMP.

OpenMP::Simple - provides C MACROS and convenient runtime functions for use in the Perl environment; e.g., PerlOMP_GETENV_BASIC.

OpenMP::Environment - provides accessors for environmental variables the OpenMP run-time considers important; e.g., OMP_NUM_THREADS.

METHODS

There are just 2 methods,

new

constructor, only needed if you're going to use the next method, which means you're updating OpenMP variables in the environment.

env

chainable accessor to the OpenMP::Environment reference that is created when the constructor new used.

SEE ALSO

This is a module that aims at making it easier to bootstrap Perl+OpenMP programs. It is designed to work together with OpenMP::Environment and OpenMP::Simple.

Project website: https://github.com/Perl-OpenMP.

This module heavily favors the GOMP implementation of the OpenMP specification within gcc. In fact, it has not been tested with any other implementations because Alien::OpenMP doesn't support anything other than GCC at the time of this writing due to lack of anyone asking for it.

https://gcc.gnu.org/onlinedocs/libgomp/index.html

Please also see the rperl project for a glimpse into the potential future of Perl+OpenMP, particularly in regards to thread-safe data structures.

https://www.rperl.org

AUTHOR

Brett Estrade <oodler@cpan.org>

LICENSE & COPYRIGHT

Same as Perl.