Retro68/gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-3.c

82 lines
2.1 KiB
C
Raw Normal View History

2015-08-28 15:33:40 +00:00
/* { dg-do run } */
/* double reductions. */
#include <stdlib.h>
2017-04-10 11:32:00 +00:00
#include "reduction.h"
2015-08-28 15:33:40 +00:00
2019-06-02 15:48:37 +00:00
#define ng 8
#define nw 4
#define vl 32
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
static void
test_reductions (void)
2015-08-28 15:33:40 +00:00
{
2017-04-10 11:32:00 +00:00
const int n = 10;
2015-08-28 15:33:40 +00:00
int i;
2017-04-10 11:32:00 +00:00
double array[n];
2015-08-28 15:33:40 +00:00
for (i = 0; i < n; i++)
2017-04-10 11:32:00 +00:00
array[i] = i+1;
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
/* Gang reductions. */
check_reduction_op (double, +, 0, array[i], num_gangs (ng), gang);
check_reduction_op (double, *, 1, array[i], num_gangs (ng), gang);
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
/* Worker reductions. */
check_reduction_op (double, +, 0, array[i], num_workers (nw), worker);
check_reduction_op (double, *, 1, array[i], num_workers (nw), worker);
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
/* Vector reductions. */
check_reduction_op (double, +, 0, array[i], vector_length (vl), vector);
check_reduction_op (double, *, 1, array[i], vector_length (vl), vector);
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
/* Combined reductions. */
check_reduction_op (double, +, 0, array[i], num_gangs (ng) num_workers (nw)
vector_length (vl), gang worker vector);
check_reduction_op (double, *, 1, array[i], num_gangs (ng) num_workers (nw)
vector_length (vl), gang worker vector);
}
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
static void
test_reductions_minmax (void)
{
const int n = 1000;
int i;
double array[n];
2015-08-28 15:33:40 +00:00
for (i = 0; i < n; i++)
2017-04-10 11:32:00 +00:00
array[i] = i;
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
/* Gang reductions. */
check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng), gang);
check_reduction_macro (double, max, -1, array[i], num_gangs (ng), gang);
/* Worker reductions. */
check_reduction_macro (double, min, n + 1, array[i], num_workers (nw),
worker);
check_reduction_macro (double, max, -1, array[i], num_workers (nw), worker);
/* Vector reductions. */
check_reduction_macro (double, min, n + 1, array[i], vector_length (vl),
vector);
check_reduction_macro (double, max, -1, array[i], vector_length (vl),
vector);
/* Combined reductions. */
check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng)
num_workers (nw) vector_length (vl), gang worker
vector);
check_reduction_macro (double, max, -1, array[i], num_gangs (ng)
num_workers (nw) vector_length (vl), gang worker
vector);
}
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
int
main (void)
{
test_reductions ();
test_reductions_minmax ();
2015-08-28 15:33:40 +00:00
return 0;
}