ARGOBOTS  66b1c39742507d8df30e8d28c54839b961a14814
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
self.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #include "abti.h"
7 
35 {
36  *type = ABT_UNIT_TYPE_EXT;
37 
38  /* Deprecated: if Argobots has not been initialized, set type to
39  * ABT_UNIT_TYPE_EXT. */
40  ABTI_xstream *p_local_xstream;
41  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
42  *type = ABTI_thread_type_get_type(p_local_xstream->p_thread->type);
43  return ABT_SUCCESS;
44 }
45 
63 {
64  ABTI_xstream *p_local_xstream;
65  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
66 
67  ABTI_thread *p_thread = p_local_xstream->p_thread;
68  *flag = (p_thread->type & ABTI_THREAD_TYPE_MAIN) ? ABT_TRUE : ABT_FALSE;
69  return ABT_SUCCESS;
70 }
71 
88 {
89  ABTI_xstream *p_local_xstream;
90  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
91 
92  /* Return value */
93  *flag = (p_local_xstream->type == ABTI_XSTREAM_TYPE_PRIMARY) ? ABT_TRUE
94  : ABT_FALSE;
95  return ABT_SUCCESS;
96 }
97 
116 int ABT_self_get_last_pool_id(int *pool_id)
117 {
118  ABTI_SETUP_WITH_INIT_CHECK();
119  ABTI_xstream *p_local_xstream =
120  ABTI_local_get_xstream_or_null(ABTI_local_get_local());
121  if (ABTI_IS_EXT_THREAD_ENABLED && !p_local_xstream) {
122  /* This is when an external thread called this routine. */
123  *pool_id = -1;
124  } else {
125  ABTI_thread *p_self = p_local_xstream->p_thread;
126  ABTI_ASSERT(p_self->p_pool);
127  *pool_id = p_self->p_pool->id;
128  }
129  return ABT_SUCCESS;
130 }
131 
151 {
152  ABTI_xstream *p_local_xstream;
153  ABTI_ythread *p_self;
154  ABTI_SETUP_LOCAL_YTHREAD_WITH_INIT_CHECK(&p_local_xstream, &p_self);
155 
156  ABTI_ythread_set_blocked(p_self);
157  ABTI_ythread_suspend(&p_local_xstream, p_self, ABT_SYNC_EVENT_TYPE_USER,
158  NULL);
159  return ABT_SUCCESS;
160 }
161 
175 int ABT_self_set_arg(void *arg)
176 {
177  ABTI_xstream *p_local_xstream;
178  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
179 
180  p_local_xstream->p_thread->p_arg = arg;
181  return ABT_SUCCESS;
182 }
183 
200 int ABT_self_get_arg(void **arg)
201 {
202  ABTI_xstream *p_local_xstream;
203  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
204 
205  *arg = p_local_xstream->p_thread->p_arg;
206  return ABT_SUCCESS;
207 }
208 
225 {
226  ABTI_xstream *p_local_xstream;
227  ABTI_SETUP_LOCAL_XSTREAM_WITH_INIT_CHECK(&p_local_xstream);
228 
229  *flag = (p_local_xstream->p_thread->type & ABTI_THREAD_TYPE_NAMED)
230  ? ABT_FALSE
231  : ABT_TRUE;
232  return ABT_SUCCESS;
233 }
int ABT_self_set_arg(void *arg) ABT_API_PUBLIC
Set the argument for the work unit function.
Definition: self.c:175
int ABT_bool
Definition: abt.h:373
int ABT_self_get_type(ABT_unit_type *type) ABT_API_PUBLIC
Return the type of calling work unit.
Definition: self.c:34
#define ABT_FALSE
Definition: abt.h:285
#define ABT_SUCCESS
Definition: abt.h:64
#define ABT_TRUE
Definition: abt.h:284
ABT_unit_type
Definition: abt.h:169
int ABT_self_suspend(void) ABT_API_PUBLIC
Suspend the current ULT.
Definition: self.c:150
int ABT_self_get_arg(void **arg) ABT_API_PUBLIC
Retrieve the argument for the work unit function.
Definition: self.c:200
int ABT_self_is_unnamed(ABT_bool *flag) ABT_API_PUBLIC
Check if the running work unit is unnamed.
Definition: self.c:224
int ABT_self_get_last_pool_id(int *pool_id) ABT_API_PUBLIC
Get the last pool's ID of calling work unit.
Definition: self.c:116
int ABT_self_is_primary(ABT_bool *flag) ABT_API_PUBLIC
Check if the caller is the primary ULT.
Definition: self.c:62
int ABT_self_on_primary_xstream(ABT_bool *flag) ABT_API_PUBLIC
Check if the caller's ES is the primary ES.
Definition: self.c:87