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 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
[
qw/1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1/
],
];
my
$expected
= [ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, ];
foreach
my
$thread_count
(
qw/1 2 4 8 16/
) {
$env
->omp_num_threads(
$thread_count
);
my
$aref_new
= omp_get_renew_aref(
$aref_orig
,
scalar
@{
$aref_orig
->[0]} );
my
$seen_rows
=
shift
@$aref_new
;
my
$seen_threads
=
shift
@$aref_new
;
is
$seen_rows
,
scalar
@$aref_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}
;
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_2D_AoA_TO_2D_FLOAT_ARRAY worked to convert original ARRAY reference to raw C 2D array of floats}
;
}
done_testing;