LLVM OpenMP
22.0.0git
runtime
test
misc_bugs
teams-no-par.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
//
3
// The test checks the teams construct pseudocode executed on host
4
//
5
6
#include <stdio.h>
7
#include <omp.h>
8
9
#ifndef N_TEAMS
10
#define N_TEAMS 4
11
#endif
12
#ifndef N_THR
13
#define N_THR 3
14
#endif
15
16
static
int
err
= 0;
17
18
// Internal library staff to emulate compiler's code generation:
19
#ifdef __cplusplus
20
extern
"C"
{
21
#endif
22
23
typedef
struct
{
24
int
reserved_1
;
25
int
flags
;
26
int
reserved_2
;
27
int
reserved_3
;
28
char
*
psource
;
29
}
ident_t
;
30
31
static
ident_t
dummy_loc
= {0, 2, 0, 0,
";dummyFile;dummyFunc;0;0;;"
};
32
33
int
__kmpc_global_thread_num
(
void
*);
34
void
__kmpc_push_num_teams
(
ident_t
const
*,
int
,
int
,
int
);
35
void
__kmpc_fork_teams
(
ident_t
const
*,
int
argc,
void
*
microtask
, ...);
36
37
#ifdef __cplusplus
38
}
39
#endif
40
41
// Outlined entry point:
42
void
foo
(
int
*gtid,
int
*tid,
int
*nt)
43
{
// start "serial" execution by master threads of each team
44
if
( nt ) {
45
printf(
" team %d, param %d\n"
, omp_get_team_num(), *nt);
46
}
else
{
47
printf(
"ERROR: teams before parallel: gtid, tid: %d %d, bad pointer: %p\n"
, *gtid, *tid, nt);
48
err
++;
49
return
;
50
}
51
}
52
53
int
main
()
54
{
55
int
nt = 4;
56
int
th =
__kmpc_global_thread_num
(NULL);
// registers initial thread
57
__kmpc_push_num_teams
(&
dummy_loc
, th,
N_TEAMS
,
N_THR
);
58
__kmpc_fork_teams
(&
dummy_loc
, 1, &
foo
, &nt);
// pass 1 shared parameter "nt"
59
if
(
err
)
60
printf(
"failed with %d errors\n"
,
err
);
61
else
62
printf(
"passed\n"
);
63
return
err
;
64
}
microtask
void microtask(int *global_tid, int *bound_tid)
Definition
omp__kmpc_fork_call_if.c:21
foo
void foo(int x)
Definition
omp_nothing.c:6
ident_t
Definition
teams-no-par.c:23
ident_t::psource
char * psource
Definition
teams-no-par.c:28
ident_t::reserved_3
int reserved_3
Definition
teams-no-par.c:27
ident_t::reserved_1
int reserved_1
Definition
teams-no-par.c:24
ident_t::flags
int flags
Definition
teams-no-par.c:25
ident_t::reserved_2
int reserved_2
Definition
teams-no-par.c:26
foo
void foo()
Definition
target_thread_limit.cpp:7
__kmpc_global_thread_num
int __kmpc_global_thread_num(void *)
N_TEAMS
#define N_TEAMS
Definition
teams-no-par.c:10
err
static int err
Definition
teams-no-par.c:16
dummy_loc
static ident_t dummy_loc
Definition
teams-no-par.c:31
__kmpc_push_num_teams
void __kmpc_push_num_teams(ident_t const *, int, int, int)
N_THR
#define N_THR
Definition
teams-no-par.c:13
__kmpc_fork_teams
void __kmpc_fork_teams(ident_t const *, int argc, void *microtask,...)
main
int main()
Definition
teams-no-par.c:53
Generated on
for LLVM OpenMP by
1.14.0