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

85 lines
2.3 KiB
C
Raw Normal View History

2015-08-28 15:33:40 +00:00
/* { dg-do run } */
2017-04-10 11:32:00 +00:00
/* Ignore vector_length warnings for offloaded (nvptx) targets. */
/* { dg-additional-options "-foffload=-w" } */
2015-08-28 15:33:40 +00:00
/* double reductions. */
#include <stdlib.h>
2017-04-10 11:32:00 +00:00
#include "reduction.h"
2015-08-28 15:33:40 +00:00
2017-04-10 11:32:00 +00:00
const int ng = 8;
const int nw = 4;
const int 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;
}