Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perl-openmp/p5-openmp
Metapackage for using OpenMP in Perl
https://github.com/perl-openmp/p5-openmp
Last synced: about 1 month ago
JSON representation
Metapackage for using OpenMP in Perl
- Host: GitHub
- URL: https://github.com/perl-openmp/p5-openmp
- Owner: Perl-OpenMP
- Created: 2024-07-19T20:55:14.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-07-20T20:54:47.000Z (5 months ago)
- Last Synced: 2024-07-20T23:46:34.093Z (5 months ago)
- Language: Perl
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Change
Awesome Lists containing this project
README
This is a metapackage for using OpenMP and Perl.
```perl
#!/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_UPDATE_WITH_ENV__NUM_THREADS /* <~ MACRO x OpenMP::Simple */
#pragma omp parallel
{
#pragma omp single
ret = omp_get_num_threads();
}
return ret;
}__END__
```