| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef UCT_UGNI_DEF_H |
| 8 |
#define UCT_UGNI_DEF_H |
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
# include "config.h" |
| 12 |
#endif |
| 13 |
|
| 14 |
#include <uct/base/uct_worker.h> |
| 15 |
#include <ucs/async/async.h> |
| 16 |
|
| 17 |
#define UCT_UGNI_MD_NAME "ugni" |
| 18 |
#define UCT_UGNI_HASH_SIZE 256 |
| 19 |
#define UCT_UGNI_MAX_DEVICES 2 |
| 20 |
#define UCT_UGNI_LOCAL_CQ 8192 |
| 21 |
#define UCT_UGNI_RKEY_MAGIC 0xdeadbeefLL |
| 22 |
#define UCT_UGNI_MAX_TYPE_NAME 10 |
| 23 |
#define LEN_64 (sizeof(uint64_t)) |
| 24 |
#define LEN_32 (sizeof(uint32_t)) |
| 25 |
#define UGNI_GET_ALIGN 4 |
| 26 |
#define UCT_UGNI_INIT_FLUSH 1 |
| 27 |
#define UCT_UGNI_INIT_FLUSH_REQ 2 |
| 28 |
|
| 29 |
#define UCT_UGNI_ZERO_LENGTH_POST(len) \ |
| 30 |
if (0 == len) { \ |
| 31 |
ucs_trace_data("Zero length request: skip it"); \ |
| 32 |
return UCS_OK; \ |
| 33 |
} |
| 34 |
|
| 35 |
#define uct_ugni_enter_async(x) \ |
| 36 |
do {\ |
| 37 |
ucs_trace_async("Taking lock on worker %p", (x)->super.worker); \ |
| 38 |
UCS_ASYNC_BLOCK((x)->super.worker->async); \ |
| 39 |
} while(0) |
| 40 |
|
| 41 |
#define uct_ugni_leave_async(x) \ |
| 42 |
do {\ |
| 43 |
ucs_trace_async("Releasing lock on worker %p", (x)->super.worker); \ |
| 44 |
UCS_ASYNC_UNBLOCK((x)->super.worker->async); \ |
| 45 |
} while(0) |
| 46 |
|
| 47 |
#if ENABLE_MT |
| 48 |
#define uct_ugni_check_lock_needed(_cdm) UCS_THREAD_MODE_MULTI == (_cdm)->thread_mode |
| 49 |
#define uct_ugni_cdm_init_lock(_cdm) ucs_recursive_spinlock_init(&(_cdm)->lock, 0) |
| 50 |
#define uct_ugni_cdm_destroy_lock(_cdm) ucs_recursive_spinlock_destroy(&(_cdm)->lock) |
| 51 |
#define uct_ugni_cdm_lock(_cdm) \ |
| 52 |
if (uct_ugni_check_lock_needed(_cdm)) { \ |
| 53 |
ucs_trace_async("Taking lock"); \ |
| 54 |
ucs_recursive_spin_lock(&(_cdm)->lock); \ |
| 55 |
} |
| 56 |
#define uct_ugni_cdm_unlock(_cdm) \ |
| 57 |
if (uct_ugni_check_lock_needed(_cdm)) { \ |
| 58 |
ucs_trace_async("Releasing lock"); \ |
| 59 |
ucs_recursive_spin_unlock(&(_cdm)->lock); \ |
| 60 |
} |
| 61 |
#else |
| 62 |
#define uct_ugni_cdm_init_lock(x) UCS_OK |
| 63 |
#define uct_ugni_cdm_destroy_lock(x) {} |
| 64 |
#define uct_ugni_cdm_lock(x) |
| 65 |
#define uct_ugni_cdm_unlock(x) |
| 66 |
#define uct_ugni_check_lock_needed(x) 0 |
| 67 |
#endif |
| 68 |
|
| 69 |
#endif |