-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathalienfile
73 lines (66 loc) · 1.98 KB
/
alienfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- mode: perl -*-
use alienfile;
use Alien::Build::CommandSequence;
use lib q{lib};
use Alien::OpenMP::configure;
no lib q{lib};
configure {
if ($^O eq 'darwin') {
requires 'File::Which' => '1.27';
requires 'Path::Tiny' => '0.053';
}
if (!Alien::OpenMP::configure->is_known) {
Alien::OpenMP::configure->unsupported(__PACKAGE__);
exit;
}
};
meta->interpolator->replace_helper(cc => sub { $Alien::OpenMP::configure::CCNAME });
plugin 'Probe::CBuilder' => (
lang => 'C',
cflags => Alien::OpenMP::configure->cflags,
libs => Alien::OpenMP::configure->libs,
options => {quiet => 0},
program => join("\n" => <DATA>),
);
after probe => sub {
# only reached on success AFAICT
my $build = shift;
$build->install_prop->{'alien_openmp_compiler_has_openmp'} = 1;
$build->runtime_prop->{auto_include} = Alien::OpenMP::configure->auto_include;
my $seq = Alien::Build::CommandSequence->new([
join(' ', '%{cc}', '-dM', Alien::OpenMP::configure->cflags, '-E', '-', '<', '%{devnull}'),
sub {
my ($build, $args) = @_;
my @props = qw{openmp_version version};
my $runtime = Alien::OpenMP::configure->version_from_preprocessor($args->{out});
@{$build->runtime_prop}{@props} = @$runtime{@props};
}
]);
$seq->execute($build);
};
share {
before download => sub {
my $build = shift;
Alien::OpenMP::configure->unsupported($build);
exit;
};
};
__DATA__
/*
the following should only pass if running in a properly
supported OpenMP environment; modifications to this should
ensure it's not just testing for a successful compile and link
*/
// done before thread fork
#include <omp.h>
int main () {
omp_set_num_threads(3);
int ans = 42;
// thread section follows
#pragma omp parallel
#pragma omp master
ans = omp_get_num_threads(); // done in parallel section, but only by master thread (0)
if (3 == ans)
return 0; // good
return 1; // bad
} // end of implicit main