ovni/test/rt/nodes/taskiter.c

30 lines
588 B
C
Raw Normal View History

2023-04-14 10:25:17 +02:00
/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include "compat.h"
#include <stdio.h>
/* Adapted from Listing 2 of https://arxiv.org/pdf/2208.06332.pdf */
int
main(void)
{
int A;
#pragma oss task out(A) label("init")
2023-04-14 10:25:17 +02:00
A = 1;
#pragma oss taskiter in(A) out(A) label("iter")
2023-04-14 10:25:17 +02:00
for (int i = 0; i < 10; i++) {
#pragma oss task in(A) label("sleep")
2023-04-14 10:25:17 +02:00
sleep_us(10 + A);
#pragma oss task out(A) label ("add")
2023-04-14 10:25:17 +02:00
A = A + 1;
}
# pragma oss task in(A) label("print")
2023-04-14 10:25:17 +02:00
printf("A=%d\n", A);
#pragma oss taskwait
return 0;
2023-04-14 10:25:17 +02:00
}