This repository was archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher.pl
executable file
·53 lines (42 loc) · 1.5 KB
/
launcher.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw/$Bin/;
use lib qq{$Bin/../lib};
use Getopt::Long qw/GetOptionsFromArray/;
use Util::H2O::More qw/h2o opt2h2o/;
use OpenMP::Environment ();
# init options
my @opts = (qw/threads=i/);
my $o = h2o {threads => 4};
my $ret = GetOptionsFromArray( \@ARGV, $o, @opts );
=pod
This example runs an standalone executable. Though one is not
provided, the basic example with C<gcc> is:
gcc -fopenmp omp-example.c -o omp-example.x
You may then invoke this script like,
examples/launcher.pl ./omp-example.x
The C<OpenMP::Environment> module is highly effective when used
with externally compiled executables. Unlike is the case with
the examples provided that use C<Inline::C> to compile XS-based
Perl interfaces that can be used directly in Perl scripts; the
enviroment is an effective means of controlling the execution
parameters of the program. Therefore, the C<OpenMP::Environment>
is largely targed towards creating scripts and utilities that run
executables that utlize OpenMP.
An approach like this is useful for production HPC environments,
when running on large compute nodes. It's also useful as a basis
for running OpenMP-based benchmarks or test suites.
=cut
# initialize
my $oenv = OpenMP::Environment->new;
$oenv->omp_num_threads($o->threads);
my $exit_code = system( $ARGV[-1] );
if ( $exit_code == 0 ) {
#print qq{OK - now do stuff after a successful execution\n};
}
else {
print qq{Oof - something went wrong.\n};
exit $exit_code;
}
exit;