LLVM OpenMP 19.0.0git
teams-reduction.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2//
3// The test checks the teams construct with reduction executed on the host.
4//
5
6#include <stdio.h>
7#include <omp.h>
8
9#include <stdint.h>
10
11#ifndef N_TEAMS
12#define N_TEAMS 4
13#endif
14#ifndef N_THR
15#define N_THR 3
16#endif
17
18// Internal library stuff to emulate compiler's code generation:
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23typedef struct {
24 int32_t reserved_1;
25 int32_t flags;
26 int32_t reserved_2;
27 int32_t reserved_3;
28 char const *psource;
29} ident_t;
30
31static ident_t dummy_loc = {0, 2, 0, 0, ";dummyFile;dummyFunc;0;0;;"};
32
33typedef union {
34 // The global will be used as pointer, so we need to make sure that the
35 // compiler correctly aligns the global...
36 void *ptr;
37 int32_t data[8];
40
42void __kmpc_push_num_teams(ident_t *, int32_t global_tid, int32_t num_teams,
43 int32_t num_threads);
44void __kmpc_fork_teams(ident_t *, int32_t argc, void *microtask, ...);
45int32_t __kmpc_reduce(ident_t *, int32_t global_tid, int32_t num_vars,
46 size_t reduce_size, void *reduce_data, void *reduce_func,
48void __kmpc_end_reduce(ident_t *, int32_t global_tid, kmp_critical_name *lck);
49
50#ifdef __cplusplus
51}
52#endif
53
54// Outlined entry point:
55void outlined(int32_t *gtid, int32_t *tid) {
56 int32_t ret = __kmpc_reduce(&dummy_loc, *gtid, 0, 0, NULL, NULL, &crit);
58}
59
60int main() {
61 int32_t th = __kmpc_global_thread_num(NULL); // registers initial thread
64
65 // Test did not hang -> passed!
66 printf("passed\n");
67 return 0;
68}
void __kmpc_push_num_teams(ident_t *, int32_t global_tid, int32_t num_teams, int32_t num_threads)
void __kmpc_end_reduce(ident_t *, int32_t global_tid, kmp_critical_name *lck)
int32_t __kmpc_global_thread_num(ident_t *)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void * data
omp_lock_t lck
Definition: omp_lock.c:7
return ret
int32_t reserved_3
int32_t flags
char const * psource
int32_t reserved_2
int32_t reserved_1
int32_t __kmpc_reduce(ident_t *, int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, void *reduce_func, kmp_critical_name *lck)
void outlined(int32_t *gtid, int32_t *tid)
kmp_critical_name crit
#define N_TEAMS
static ident_t dummy_loc
#define N_THR
int main()
void __kmpc_fork_teams(ident_t *, int32_t argc, void *microtask,...)