Skip to content

Commit

Permalink
Merge pull request #169 from hzhou/2101_no_gpu
Browse files Browse the repository at this point in the history
infohint: add nogpu as a gpudriver_id hint
  • Loading branch information
pavanbalaji authored Jan 18, 2021
2 parents 3ae564f + 437e934 commit 7a4ed0f
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/backend/src/yaksur_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ int yaksur_info_keyval_append(yaksi_info_s * info, const char *key, const void *
infopriv->gpudriver_id = YAKSURI_GPUDRIVER_ID__CUDA;
} else if (!strncmp(val, "ze", vallen)) {
infopriv->gpudriver_id = YAKSURI_GPUDRIVER_ID__ZE;
} else if (!strncmp(val, "nogpu", vallen)) {
infopriv->gpudriver_id = YAKSURI_GPUDRIVER_ID__LAST;
} else {
assert(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/info/yaksa_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int yaksa_info_free(yaksa_info_t info)
int rc = YAKSA_SUCCESS;
yaksi_info_s *yaksi_info = (yaksi_info_s *) info;

if (yaksu_atomic_decr(&yaksi_info->refcount) > 0)
if (yaksu_atomic_decr(&yaksi_info->refcount) > 1)
goto fn_exit;

rc = yaksur_info_free_hook(yaksi_info);
Expand Down
6 changes: 3 additions & 3 deletions test/pack/pack-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ void pack_free_mem(mem_type_e type, void *hostbuf, void *devicebuf)
}
}

void pack_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info)
void pack_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter)
{
#ifdef HAVE_CUDA
pack_cuda_get_ptr_attr(inbuf, outbuf, info);
pack_cuda_get_ptr_attr(inbuf, outbuf, info, iter);
#elif defined(HAVE_ZE)
pack_ze_get_ptr_attr(inbuf, outbuf, info);
pack_ze_get_ptr_attr(inbuf, outbuf, info, iter);
#else
*info = NULL;
#endif
Expand Down
6 changes: 3 additions & 3 deletions test/pack/pack-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void pack_init_devices(void);
void pack_finalize_devices(void);
void pack_alloc_mem(int device_id, size_t size, mem_type_e type, void **hostbuf, void **devicebuf);
void pack_free_mem(mem_type_e type, void *hostbuf, void *devicebuf);
void pack_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info);
void pack_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter);
void pack_copy_content(const void *sbuf, void *dbuf, size_t size, mem_type_e type);

#ifdef HAVE_CUDA
Expand All @@ -44,7 +44,7 @@ void pack_cuda_finalize_devices(void);
void pack_cuda_alloc_mem(int device_id, size_t size, mem_type_e type, void **hostbuf,
void **devicebuf);
void pack_cuda_free_mem(mem_type_e type, void *hostbuf, void *devicebuf);
void pack_cuda_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info);
void pack_cuda_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter);
void pack_cuda_copy_content(const void *sbuf, void *dbuf, size_t size, mem_type_e type);
#endif

Expand All @@ -55,7 +55,7 @@ void pack_ze_finalize_devices(void);
void pack_ze_alloc_mem(int device_id, size_t size, mem_type_e type, void **hostbuf,
void **devicebuf);
void pack_ze_free_mem(mem_type_e type, void *hostbuf, void *devicebuf);
void pack_ze_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info);
void pack_ze_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter);
void pack_ze_copy_content(const void *sbuf, void *dbuf, size_t size, mem_type_e type);
#endif

Expand Down
5 changes: 2 additions & 3 deletions test/pack/pack-cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ void pack_cuda_free_mem(mem_type_e type, void *hostbuf, void *devicebuf)
}
}

void pack_cuda_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info)
void pack_cuda_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter)
{
static int count = 0;
if ((++count) % 2 == 0) {
if (iter % 2 == 0) {
int rc;

rc = yaksa_info_create(info);
Expand Down
5 changes: 2 additions & 3 deletions test/pack/pack-ze.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ void pack_ze_free_mem(mem_type_e type, void *hostbuf, void *devicebuf)
}
}

void pack_ze_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info)
void pack_ze_get_ptr_attr(const void *inbuf, void *outbuf, yaksa_info_t * info, int iter)
{
static int count = 0;
if ((++count) % 2 == 0) {
if (iter % 2 == 0) {
int rc;
ze_result_t zerr;
typedef struct {
Expand Down
27 changes: 25 additions & 2 deletions test/pack/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ static void swap_segments(uintptr_t * starts, uintptr_t * lengths, int x, int y)
lengths[y] = tmp;
}

static void host_only_get_ptr_attr(yaksa_info_t * info, int iter)
{
if (iter % 2 == 0) {
int rc;

rc = yaksa_info_create(info);
assert(rc == YAKSA_SUCCESS);

rc = yaksa_info_keyval_append(*info, "yaksa_gpu_driver", "nogpu", strlen("nogpu"));
assert(rc == YAKSA_SUCCESS);
} else {
*info = NULL;
}
}

char typestr[MAX_DTP_BASESTRLEN + 1] = { 0 };

int seed = -1;
Expand Down Expand Up @@ -228,8 +243,16 @@ void *runtest(void *arg)
pack_alloc_mem(tbuf_devid, tbufsize, tbuf_memtype, &tbuf_h, &tbuf_d);

yaksa_info_t pack_info, unpack_info;
pack_get_ptr_attr(sbuf_d + sobj.DTP_buf_offset, tbuf_d, &pack_info);
pack_get_ptr_attr(tbuf_d, dbuf_d + dobj.DTP_buf_offset, &unpack_info);
if (sbuf_memtype != MEM_TYPE__DEVICE && tbuf_memtype != MEM_TYPE__DEVICE) {
host_only_get_ptr_attr(&pack_info, i);
} else {
pack_get_ptr_attr(sbuf_d + sobj.DTP_buf_offset, tbuf_d, &pack_info, i);
}
if (tbuf_memtype != MEM_TYPE__DEVICE && dbuf_memtype != MEM_TYPE__DEVICE) {
host_only_get_ptr_attr(&unpack_info, i);
} else {
pack_get_ptr_attr(tbuf_d, dbuf_d + dobj.DTP_buf_offset, &unpack_info, i);
}

for (int j = 0; j < segments; j++) {
uintptr_t actual_pack_bytes;
Expand Down

0 comments on commit 7a4ed0f

Please sign in to comment.