1 /* Copyright (C) 2001-2013 Free Software Foundation, Inc.
2 This file is part of the UPC runtime Library.
3 Written by Gary Funck <gary@intrepid.com>
4 and Nenad Vukicevic <nenad@intrepid.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
32 //begin lib_max_threads_def
33 /* Maximum number of THREADS supported in this implementation */
34 #define GUPCR_THREAD_SIZE 12
35 #define GUPCR_THREADS_MAX (1 << GUPCR_THREAD_SIZE)
36 //end lib_max_threads_def
38 #if GUPCR_PTS_PACKED_REP && (GUPCR_THREADS_SIZE > GUPCR_PTS_THREAD_SIZE)
39 #error GUPCR_THREADS_MAX exceeds the size of the packed sptr threads field.
43 /* UPC thread-specific information */
44 typedef struct upc_thread_info_struct
49 #ifdef GUPCR_USE_PTHREADS
54 typedef upc_thread_info_t
*upc_thread_info_p
;
56 #define GUPCR_PROCBITS_PER_WORD OS_BITS_PER_ATOMIC_WORD
58 #define GUPCR_NUM_PROCBIT_WORDS ((GUPCR_THREADS_MAX + (GUPCR_PROCBITS_PER_WORD - 1)) \
59 / GUPCR_PROCBITS_PER_WORD)
61 /* Bit vector used to manage processes */
62 typedef os_atomic_t upc_procbits_vec_t
[GUPCR_NUM_PROCBIT_WORDS
];
64 /* UPC thread barrier ID */
65 extern GUPCR_THREAD_LOCAL
int __upc_barrier_id
;
67 /* There is one global page table per UPC program.
68 The global page table maps (thread, page) into
69 a global page number in the global memory region. */
70 typedef upc_page_num_t upc_pte_t
;
71 typedef upc_pte_t
*upc_pte_p
;
73 /* scheduling policies */
74 enum upc_sched_policy_enum
76 GUPCR_SCHED_POLICY_AUTO
, /* kernel's scheduling policy */
77 GUPCR_SCHED_POLICY_NODE
, /* schedule across nodes */
78 GUPCR_SCHED_POLICY_CPU
, /* schedule across cpus - multiple threads per CPU */
79 GUPCR_SCHED_POLICY_CPU_STRICT
/* schedule across cpus - one thread per CPU */
81 typedef enum upc_sched_policy_enum upc_sched_policy_t
;
83 /* Non-Uniform Memory Allocation */
84 enum upc_mem_policy_enum
86 GUPCR_MEM_POLICY_AUTO
, /* kernel's default NUMA policy */
87 GUPCR_MEM_POLICY_NODE
, /* allocate memory from the local node first */
88 GUPCR_MEM_POLICY_STRICT
/* allocate memory from the local node only */
90 typedef enum upc_mem_policy_enum upc_mem_policy_t
;
92 /* Data structure used keep track of cpu's that must ba avoided */
93 typedef struct upc_cpu_avoid_struct upc_cpu_avoid_t
;
94 typedef upc_cpu_avoid_t
*upc_cpu_avoid_p
;
96 /* UPC system-wide information */
97 typedef struct upc_info_struct
102 int partial_attach_start
;
103 os_heap_p runtime_heap
;
105 upc_page_num_t init_page_alloc
;
106 upc_shared_ptr_t init_heap_base
;
107 size_t init_heap_size
;
109 char *mmap_file_name
;
111 upc_page_num_t cur_page_alloc
;
112 upc_shared_ptr_t all_lock
;
113 upc_thread_info_t thread_info
[GUPCR_THREADS_MAX
];
116 upc_sched_policy_t sched_policy
;
117 upc_mem_policy_t mem_policy
;
119 typedef upc_info_t
*upc_info_p
;
121 /* system wide info */
122 extern upc_info_p __upc_info
;
124 /* The filename of the location where a runtime
125 error was detected. This is set by the various
126 debug-enabled ('g') UPC runtime library routines. */
127 extern GUPCR_THREAD_LOCAL
const char *__upc_err_filename
;
129 /* The line number of the location where a runtime
130 error was detected. This is set by the various
131 debug-enabled ('g') UPC runtime library routines. */
132 extern GUPCR_THREAD_LOCAL
unsigned int __upc_err_linenum
;
134 #define GUPCR_SET_ERR_LOC() \
137 __upc_err_filename = filename; \
138 __upc_err_linenum = linenum; \
141 #define GUPCR_CLEAR_ERR_LOC() \
144 __upc_err_filename = NULL; \
145 __upc_err_linenum = 0; \
148 /* The base address of the UPC shared section */
149 extern char GUPCR_SHARED_SECTION_START
[1];
151 /* The ending address (plus one) of the UPC shared section */
152 extern char GUPCR_SHARED_SECTION_END
[1];
154 /* The base address of the UPC compiled program info. section */
155 extern char GUPCR_PGM_INFO_SECTION_START
[1];
157 /* The ending address (plus one) of the UPC compiled program info. section */
158 extern char GUPCR_PGM_INFO_SECTION_END
[1];
160 /* The value of THREADS when defined at run time */
163 /* Current thread id */
164 extern GUPCR_THREAD_LOCAL
int MYTHREAD
;
166 #ifdef GUPCR_USE_PTHREADS
167 /* The value of UPC_PTHREADS when defined at run time */
168 extern int UPC_PTHREADS
;
171 #endif /* _UPC_DEFS_H_ */