Skip to content

Commit 58e57e6

Browse files
Merge pull request #66 from shintaro-iwasaki/OpaquePointer
Introduce opaque pointers
2 parents ebedfbb + 1749f80 commit 58e57e6

File tree

8 files changed

+100
-46
lines changed

8 files changed

+100
-46
lines changed

src/include/abt.h.in

Lines changed: 82 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -190,37 +190,88 @@ enum ABT_event_kind {
190190
#define ABT_XSTREAM_ANY_RANK -1
191191

192192
/* Data Types */
193-
typedef void * ABT_xstream; /* Execution Stream */
194-
typedef enum ABT_xstream_state ABT_xstream_state; /* ES state */
195-
typedef void * ABT_xstream_barrier; /* ES barrier */
196-
typedef void * ABT_sched; /* Scheduler */
197-
typedef void * ABT_sched_config; /* Sched-specific config */
198-
typedef enum ABT_sched_predef ABT_sched_predef; /* Predefined scheduler */
199-
typedef enum ABT_sched_state ABT_sched_state; /* Scheduler state */
200-
typedef enum ABT_sched_type ABT_sched_type; /* Scheduler type */
201-
typedef void * ABT_pool; /* Pool */
202-
typedef void * ABT_pool_config; /* Specific pool config */
203-
typedef enum ABT_pool_kind ABT_pool_kind; /* Pool kind */
204-
typedef enum ABT_pool_access ABT_pool_access; /* Pool access mode */
205-
typedef void * ABT_unit; /* Unit */
206-
typedef enum ABT_unit_type ABT_unit_type; /* Unit type */
207-
typedef void * ABT_thread; /* User-Level Thread (ULT) */
208-
typedef void * ABT_thread_attr; /* ULT attribute */
209-
typedef enum ABT_thread_state ABT_thread_state; /* ULT state */
210-
typedef uint64_t ABT_thread_id; /* ULT id */
211-
typedef void * ABT_task; /* Tasklet */
212-
typedef enum ABT_task_state ABT_task_state; /* Tasklet state */
213-
typedef void * ABT_key; /* WU-specific data key */
214-
typedef void * ABT_mutex; /* Mutex */
215-
typedef void * ABT_mutex_attr; /* Mutex attribute */
216-
typedef void * ABT_cond; /* Condition variable */
217-
typedef void * ABT_rwlock; /* Readers writer lock */
218-
typedef void * ABT_eventual; /* Eventual */
219-
typedef void * ABT_future; /* Future */
220-
typedef void * ABT_barrier; /* Barrier */
221-
typedef void * ABT_timer; /* Timer */
222-
typedef int ABT_bool; /* Boolean type */
223-
typedef enum ABT_event_kind ABT_event_kind; /* Event kind */
193+
struct ABT_xstream_opaque;
194+
struct ABT_xstream_barrier_opaque;
195+
struct ABT_sched_opaque;
196+
struct ABT_sched_config_opaque;
197+
struct ABT_pool_opaque;
198+
struct ABT_pool_config_opaque;
199+
struct ABT_unit_opaque;
200+
struct ABT_thread_opaque;
201+
struct ABT_thread_attr_opaque;
202+
struct ABT_task_opaque;
203+
struct ABT_key_opaque;
204+
struct ABT_mutex_opaque;
205+
struct ABT_mutex_attr_opaque;
206+
struct ABT_cond_opaque;
207+
struct ABT_rwlock_opaque;
208+
struct ABT_eventual_opaque;
209+
struct ABT_future_opaque;
210+
struct ABT_barrier_opaque;
211+
struct ABT_timer_opaque;
212+
213+
/* Execution Stream */
214+
typedef struct ABT_xstream_opaque * ABT_xstream;
215+
/* ES state */
216+
typedef enum ABT_xstream_state ABT_xstream_state;
217+
/* ES barrier */
218+
typedef struct ABT_xstream_barrier_opaque * ABT_xstream_barrier;
219+
/* Scheduler */
220+
typedef struct ABT_sched_opaque * ABT_sched;
221+
/* Sched-specific config */
222+
typedef struct ABT_sched_config_opaque * ABT_sched_config;
223+
/* Predefined scheduler */
224+
typedef enum ABT_sched_predef ABT_sched_predef;
225+
/* Scheduler state */
226+
typedef enum ABT_sched_state ABT_sched_state;
227+
/* Scheduler type */
228+
typedef enum ABT_sched_type ABT_sched_type;
229+
/* Pool */
230+
typedef struct ABT_pool_opaque * ABT_pool;
231+
/* Specific pool config */
232+
typedef struct ABT_pool_config_opaque * ABT_pool_config;
233+
/* Pool kind */
234+
typedef enum ABT_pool_kind ABT_pool_kind;
235+
/* Pool access mode */
236+
typedef enum ABT_pool_access ABT_pool_access;
237+
/* Unit */
238+
typedef struct ABT_unit_opaque * ABT_unit;
239+
/* Unit type */
240+
typedef enum ABT_unit_type ABT_unit_type;
241+
/* User-Level Thread (ULT) */
242+
typedef struct ABT_thread_opaque * ABT_thread;
243+
/* ULT attribute */
244+
typedef struct ABT_thread_attr_opaque * ABT_thread_attr;
245+
/* ULT state */
246+
typedef enum ABT_thread_state ABT_thread_state;
247+
/* Tasklet state */
248+
typedef enum ABT_task_state ABT_task_state;
249+
/* ULT id */
250+
typedef uint64_t ABT_thread_id;
251+
/* Tasklet */
252+
typedef struct ABT_task_opaque * ABT_task;
253+
/* WU-specific data key */
254+
typedef struct ABT_key_opaque * ABT_key;
255+
/* Mutex */
256+
typedef struct ABT_mutex_opaque * ABT_mutex;
257+
/* Mutex attribute */
258+
typedef struct ABT_mutex_attr_opaque * ABT_mutex_attr;
259+
/* Condition variable */
260+
typedef struct ABT_cond_opaque * ABT_cond;
261+
/* Readers writer lock */
262+
typedef struct ABT_rwlock_opaque * ABT_rwlock;
263+
/* Eventual */
264+
typedef struct ABT_eventual_opaque * ABT_eventual;
265+
/* Future */
266+
typedef struct ABT_future_opaque * ABT_future;
267+
/* Barrier */
268+
typedef struct ABT_barrier_opaque * ABT_barrier;
269+
/* Timer */
270+
typedef struct ABT_timer_opaque * ABT_timer;
271+
/* Boolean type */
272+
typedef int ABT_bool;
273+
/* Event kind */
274+
typedef enum ABT_event_kind ABT_event_kind;
224275

225276

226277
/* Null Object Handles */

src/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ int ABTI_info_print_thread_stacks_in_pool(FILE *fp, ABTI_pool *p_pool)
357357
fprintf(fp, "== pool (%p) ==\n", (void *)p_pool);
358358
struct ABTI_info_print_unit_arg_t arg;
359359
arg.fp = fp;
360-
arg.pool = ABTI_pool_get_handle(pool);
360+
arg.pool = pool;
361361
p_pool->p_print_all(pool, &arg, ABTI_info_print_unit);
362362

363363
fn_exit:

src/pool/pool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ int ABT_pool_add_sched(ABT_pool pool, ABT_sched sched)
457457
* a pool with another associated pool, and set the right value if
458458
* it is okay */
459459
for (p = 0; p < p_sched->num_pools; p++) {
460-
abt_errno = ABTI_pool_set_consumer(p_sched->pools[p],
461-
p_pool->consumer);
460+
abt_errno = ABTI_pool_set_consumer(
461+
ABTI_pool_get_ptr(p_sched->pools[p]), p_pool->consumer);
462462
ABTI_CHECK_ERROR(abt_errno);
463463
}
464464
break;

src/sched/sched.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,10 @@ int ABTI_sched_get_migration_pool(ABTI_sched *p_sched, ABTI_pool *source_pool,
841841
if (p_sched->num_pools == 0)
842842
p_pool = NULL;
843843
else
844-
p_pool = p_sched->pools[0];
844+
p_pool = ABTI_pool_get_ptr(p_sched->pools[0]);
845845
}
846846
else
847-
p_pool = p_sched->get_migr_pool(sched);
847+
p_pool = ABTI_pool_get_ptr(p_sched->get_migr_pool(sched));
848848

849849
/* Check the pool */
850850
if (ABTI_pool_accept_migration(p_pool, source_pool) == ABT_TRUE) {

src/stream_barrier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int ABT_xstream_barrier_create(uint32_t num_waiters, ABT_xstream_barrier *newbar
103103
* @return Error code
104104
* @retval ABT_SUCCESS on success
105105
*/
106-
int ABT_xstream_barrier_free(ABT_barrier *barrier)
106+
int ABT_xstream_barrier_free(ABT_xstream_barrier *barrier)
107107
{
108108
#ifdef HAVE_PTHREAD_BARRIER_INIT
109109
int abt_errno = ABT_SUCCESS;

src/task.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ int ABTI_task_create_sched(ABTI_local *p_local, ABTI_pool *p_pool,
8181
void *arg = (void *)ABTI_sched_get_handle(p_sched);
8282
/* If p_sched is reused, ABTI_task_revive() can be used. */
8383
if (p_sched->p_task) {
84-
abt_errno = ABTI_task_revive(p_local, p_pool, p_sched->run, arg,
84+
abt_errno = ABTI_task_revive(p_local, p_pool,
85+
(void (*)(void *))p_sched->run, arg,
8586
p_sched->p_task);
8687
ABTI_CHECK_ERROR(abt_errno);
8788
goto fn_exit;
8889
}
8990

9091
/* Allocate a task object */
91-
abt_errno = ABTI_task_create(p_local, p_pool, p_sched->run, arg, p_sched, 1,
92-
&p_newtask);
92+
abt_errno = ABTI_task_create(p_local, p_pool,
93+
(void (*)(void *))p_sched->run, arg, p_sched,
94+
1, &p_newtask);
9395
ABTI_CHECK_ERROR(abt_errno);
9496

9597
fn_exit:

src/thread.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ int ABT_thread_free_many(int num, ABT_thread *thread_list)
345345
int i;
346346

347347
for (i = 0; i < num; i++) {
348-
ABTI_thread *p_thread = ABTI_thread_get_ptr(&thread_list[i]);
348+
ABTI_thread *p_thread = ABTI_thread_get_ptr(thread_list[i]);
349349
ABTI_thread_free(p_local, p_thread);
350350
}
351351
return ABT_SUCCESS;
@@ -1720,7 +1720,8 @@ int ABTI_thread_create_sched(ABTI_local *p_local, ABTI_pool *p_pool,
17201720
/* If p_sched is reused, ABTI_thread_revive() can be used. */
17211721
if (p_sched->p_thread) {
17221722
ABT_sched h_sched = ABTI_sched_get_handle(p_sched);
1723-
abt_errno = ABTI_thread_revive(p_local, p_pool, p_sched->run,
1723+
abt_errno = ABTI_thread_revive(p_local, p_pool,
1724+
(void (*)(void *))p_sched->run,
17241725
(void *)h_sched, p_sched->p_thread);
17251726
ABTI_CHECK_ERROR(abt_errno);
17261727
goto fn_exit;
@@ -1729,9 +1730,9 @@ int ABTI_thread_create_sched(ABTI_local *p_local, ABTI_pool *p_pool,
17291730
/* Allocate a ULT object and its stack */
17301731
ABTI_thread_attr_init(&attr, NULL, ABTI_global_get_sched_stacksize(),
17311732
ABTI_STACK_TYPE_MALLOC, ABT_FALSE);
1732-
abt_errno = ABTI_thread_create_internal(p_local, p_pool, p_sched->run,
1733-
(void *)ABTI_sched_get_handle(p_sched), &attr, ABTI_THREAD_TYPE_USER,
1734-
p_sched, 1, NULL, ABT_TRUE, &p_newthread);
1733+
abt_errno = ABTI_thread_create_internal(p_local, p_pool,
1734+
(void (*)(void *))p_sched->run, (void *)ABTI_sched_get_handle(p_sched),
1735+
&attr, ABTI_THREAD_TYPE_USER, p_sched, 1, NULL, ABT_TRUE, &p_newthread);
17351736
ABTI_CHECK_ERROR(abt_errno);
17361737

17371738
fn_exit:

test/basic/task_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void task_create(void *arg)
8080
int my_id = (int)(intptr_t)arg;
8181
ABT_thread my_thread;
8282
ABT_pool my_pool;
83-
ABT_thread *tasks;
83+
ABT_task *tasks;
8484

8585
ret = ABT_thread_self(&my_thread);
8686
ATS_ERROR(ret, "ABT_thread_self");

0 commit comments

Comments
 (0)