Portal:Perl+OpenMP: Difference between revisions

From Perl Guilds - Getting Medieval with Perl
Jump to navigation Jump to search
Created page with "== Introduction == WIth most perl binaries compiled with a version of GCC that [https://gcc.gnu.org/projects/gomp/ 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 ==== See main projec..."
 
No edit summary
 
Line 50: Line 50:
  }
  }
  __END__
  __END__
Alternate Compiler Support


== Alternate Compiler Support ==
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.
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 ===
In principle, `Alien::OpenMP` supports clang.
=== Intel OneAPI ===
section in progress ... (track at https://github.com/Perl-OpenMP/p5-Alien-OpenMP/issues/25)


== Special Topics ==
== Special Topics ==
=== Perl+OpenMP and wxPerl ===
See https://github.com/Perl-OpenMP/p5-OpenMP-wxPerl for a demo.
[[File:400638381-d93611d5-e068-4130-821a-b6da55101545.png|thumb|Example wxPerl application controlling real OpenMP threads in realtime. Demo project hosted [https://github.com/Perl-OpenMP/p5-OpenMP-wxPerl here].]]


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

Latest revision as of 15:40, 23 January 2025

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.

Example wxPerl application controlling real OpenMP threads in realtime. Demo project hosted here.

Intel Xeon Phi Co-Processor

[edit | edit source]

section in process ...(track https://github.com/Perl-OpenMP/p5-Alien-OpenMP/issues/26)