Skip to content

Commit

Permalink
test/pack: use iteration number to split info hint testing
Browse files Browse the repository at this point in the history
The static counter is not thread-safe. Use iteration number to get more
consistent split-testing.

Signed-off-by: Hui Zhou <[email protected]>
  • Loading branch information
hzhou committed Jan 17, 2021
1 parent aafca77 commit 437e934
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
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
13 changes: 6 additions & 7 deletions test/pack/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ 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 void host_only_get_ptr_attr(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 Expand Up @@ -245,14 +244,14 @@ void *runtest(void *arg)

yaksa_info_t pack_info, unpack_info;
if (sbuf_memtype != MEM_TYPE__DEVICE && tbuf_memtype != MEM_TYPE__DEVICE) {
host_only_get_ptr_attr(&pack_info);
host_only_get_ptr_attr(&pack_info, i);
} else {
pack_get_ptr_attr(sbuf_d + sobj.DTP_buf_offset, tbuf_d, &pack_info);
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);
host_only_get_ptr_attr(&unpack_info, i);
} else {
pack_get_ptr_attr(tbuf_d, dbuf_d + dobj.DTP_buf_offset, &unpack_info);
pack_get_ptr_attr(tbuf_d, dbuf_d + dobj.DTP_buf_offset, &unpack_info, i);
}

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

0 comments on commit 437e934

Please sign in to comment.