Skip to content

Commit

Permalink
test: add nogpu hint to pack tests when no device memory
Browse files Browse the repository at this point in the history
Apply nogpu hint every other test when no device memory is involved.
  • Loading branch information
hzhou committed Jan 14, 2021
1 parent 6d4081c commit e4fbfd2
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/pack/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ 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)
{
static int count = 0;
static yaksa_info_t nogpu_info;
if (count == 0) {
int rc;

rc = yaksa_info_create(&nogpu_info);
assert(rc == YAKSA_SUCCESS);

rc = yaksa_info_keyval_append(nogpu_info, "yaksa_gpu_driver", "nogpu", strlen("nogpu"));
assert(rc == YAKSA_SUCCESS);
}
if ((++count) % 2 == 0) {
*info = &nogpu_info;
} else {
*info = NULL;
}
}

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

int seed = -1;
Expand Down Expand Up @@ -228,8 +248,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_d != MEM_TYPE__DEVICE) {
host_only_get_ptr_attr(&pack_info);
} else {
pack_get_ptr_attr(sbuf_d + sobj.DTP_buf_offset, tbuf_d, &pack_info);
}
if (tbuf_memtype != MEM_TYPE__DEVICE && dbuf_d != MEM_TYPE__DEVICE) {
host_only_get_ptr_attr(&unpack_info);
} else {
pack_get_ptr_attr(tbuf_d, dbuf_d + dobj.DTP_buf_offset, &unpack_info);
}

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

0 comments on commit e4fbfd2

Please sign in to comment.