|
#!/usr/bin/env perl
my $has_test_deep = 1;
BEGIN {
if ($] < 5.012) {
$has_test_deep = 0;
}
else {
eval { require Test::Deep; Test::Deep-> import (); 1 } or $has_test_deep = 0; }
if (not $has_test_deep ) {
no warnings qw/redefine/ ;
eval { *cmp_deeply = sub { 1 } };
}
}
C => 'DATA' ,
with => qw/OpenMP::Simple/ ,
);
my $env = OpenMP::Environment->new();
my $aref_orig = [
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
[ 1 .. 10 ],
];
my $expected = [ qw/1 2 3 4 5 6 7 8 9 10/ ];
foreach my $thread_count ( qw/1 4 8/ ) {
$env ->omp_num_threads( $thread_count );
foreach my $row_orig ( @$aref_orig ) {
my $aref_new = omp_get_renew_aref( $row_orig );
my $seen_elements = shift @$aref_new ;
my $seen_threads = shift @$aref_new ;
is $seen_elements , scalar @$row_orig , q{PerlOMP_1D_Array_NUM_ELEMENTS works on original ARRAY reference} ;
is $seen_threads , $thread_count , qq{OMP_NUM_THREADS=$thread_count is respected inside of the, omp parallel section, as expected} ;
if ( $has_test_deep ) {
cmp_deeply $aref_new , $expected , qq{Row summed array ref returned as expected from $thread_count OpenMP threads} ;
cmp_deeply $aref_new , $expected , qq{PerlOMP_1D_Array_TO_1D_INT_ARRAY worked to convert original ARRAY reference to raw C 1D array of floats} ;
}
else {
SKIP: { skip "Skipping cmp_deeply tests because Perl is below 5.12 or Test::Deep is unavailable" , 2; }
}
}
}
done_testing;
|