Skip to content

Commit

Permalink
support gdr malloc&free
Browse files Browse the repository at this point in the history
  • Loading branch information
starkhu committed Dec 23, 2024
1 parent cb79eb3 commit 5e74cb9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ USE_ILUVATAR_COREX ?= 0
USE_CAMBRICON ?= 0

# set to empty if not provided
DEVICE_HOME ?=
CCL_HOME ?=
DEVICE_HOME ?=
CCL_HOME ?=

ifeq ($(strip $(DEVICE_HOME)),)
ifeq ($(USE_NVIDIA), 1)
DEVICE_HOME = /usr/local/cuda
else ifeq ($(USE_ILUVATAR_COREX), 1)
DEVICE_HOME = /usr/local/corex
else ifeq ($(USE_CAMBRICON), 1)
DEVICE_HOME = /torch/neuware_home
DEVICE_HOME = $(NEUWARE_HOME)
else
DEVICE_HOME = /usr/local/cuda
endif
Expand All @@ -27,7 +27,7 @@ ifeq ($(strip $(CCL_HOME)),)
else ifeq ($(USE_ILUVATAR_COREX), 1)
CCL_HOME = /usr/local/corex
else ifeq ($(USE_CAMBRICON), 1)
CCL_HOME = /torch/neuware_home
CCL_HOME = $(NEUWARE_HOME)
else
CCL_HOME = /usr/local/nccl/build
endif
Expand Down
7 changes: 5 additions & 2 deletions flagcx/adaptor/cncl_adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ flagcxResult_t cnclAdaptorCommInitRank(flagcxHomoComm_t *comm, int nranks, flagc
if (*comm == NULL) {
flagcxCalloc(comm, 1);
}
return (flagcxResult_t)cnclInitComms(&(*comm)->base, 1/*num_comm*/, &rank/*dev_list*/,
&rank/*rank_list*/, nranks, (cnclCliqueId *)commId);
unsigned int device_count = 0;
DEVCHECK(cnrtGetDeviceCount(&device_count));
int dev_id = rank % device_count;
return (flagcxResult_t)c2f_ret_map[cnclInitComms(&(*comm)->base, 1/*num_comm*/, &dev_id/*dev_list*/,
&rank/*rank_list*/, nranks, (cnclCliqueId *)commId)];
}

//TODO: unsupported
Expand Down
12 changes: 9 additions & 3 deletions flagcx/adaptor/mlu_adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ flagcxResult_t mluAdaptorDeviceMemcpy(void *dst, void *src, size_t size, flagcxM
if (stream == NULL) {
DEVCHECK(cnrtMemcpy(dst, src, size, memcpy_type_map[type]));
} else {
DEVCHECK(cnrtMemcpyAsync_V3(dst, src, size, stream->base, memcpy_type_map[type]));
DEVCHECK(cnrtMemcpyAsync_V2(dst, src, size, stream->base, memcpy_type_map[type]));
}
return flagcxSuccess;
}
Expand Down Expand Up @@ -73,12 +73,18 @@ flagcxResult_t mluAdaptorGetVendor(char *vendor) {
}

flagcxResult_t mluAdaptorGdrMemAlloc(void **ptr, size_t size, void *memHandle) {
// TODO: Implement GDR memory allocation
if (ptr == NULL) {
return flagcxInvalidArgument;
}
DEVCHECK(cnrtMalloc(ptr, size));
return flagcxSuccess;
}

flagcxResult_t mluAdaptorGdrMemFree(void *ptr, void *memHandle) {
// TODO: Implement GDR memory free
if (ptr == NULL) {
return flagcxSuccess;
}
DEVCHECK(cnrtFree(ptr));
return flagcxSuccess;
}

Expand Down

0 comments on commit 5e74cb9

Please sign in to comment.