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;
|
2023-12-01 17:13:09 +01:00
|
|
|
#pragma oss task out(A) label("init")
|
2023-04-14 10:25:17 +02:00
|
|
|
A = 1;
|
|
|
|
|
2023-12-01 17:13:09 +01:00
|
|
|
#pragma oss taskiter in(A) out(A) label("iter")
|
2023-04-14 10:25:17 +02:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2023-12-01 17:13:09 +01:00
|
|
|
#pragma oss task in(A) label("sleep")
|
2023-04-14 10:25:17 +02:00
|
|
|
sleep_us(10 + A);
|
2023-12-01 17:13:09 +01:00
|
|
|
#pragma oss task out(A) label ("add")
|
2023-04-14 10:25:17 +02:00
|
|
|
A = A + 1;
|
|
|
|
}
|
|
|
|
|
2023-12-01 17:13:09 +01:00
|
|
|
# pragma oss task in(A) label("print")
|
2023-04-14 10:25:17 +02:00
|
|
|
printf("A=%d\n", A);
|
2023-12-01 17:13:09 +01:00
|
|
|
|
|
|
|
#pragma oss taskwait
|
|
|
|
return 0;
|
2023-04-14 10:25:17 +02:00
|
|
|
}
|