Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
minmingzhu committed Nov 1, 2024
1 parent d38a4e4 commit 358cd89
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 52 deletions.
43 changes: 1 addition & 42 deletions mllib-dal/src/main/native/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ std::vector<sycl::device> get_gpus() {
}

static int getLocalRank(ccl::communicator &comm, int size, int rank) {
const int MPI_MAX_PROCESSOR_NAME = 128;
/* Obtain local rank among nodes sharing the same host name */
char zero = static_cast<char>(0);
std::vector<char> name(MPI_MAX_PROCESSOR_NAME + 1, zero);
Expand Down Expand Up @@ -112,45 +113,3 @@ sycl::queue getQueue(const ComputeDevice device) {
}
}
}

preview::spmd::communicator<preview::spmd::device_memory_access::usm>
createDalCommunicator(const jint executorNum, const jint rank,
const ccl::string ccl_ip_port) {
auto gpus = get_gpus();

auto t1 = std::chrono::high_resolution_clock::now();

ccl::init();

auto t2 = std::chrono::high_resolution_clock::now();
auto duration =
(float)std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1)
.count();

logger::println(logger::INFO, "OneCCL singleton init took %f secs",
duration / 1000);

t1 = std::chrono::high_resolution_clock::now();

auto kvs_attr = ccl::create_kvs_attr();

kvs_attr.set<ccl::kvs_attr_id::ip_port>(ccl_ip_port);

ccl::shared_ptr_class<ccl::kvs> kvs = ccl::create_main_kvs(kvs_attr);

t2 = std::chrono::high_resolution_clock::now();
duration =
(float)std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1)
.count();
logger::println(logger::INFO, "OneCCL (native): create kvs took %f secs",
duration / 1000);
sycl::queue queue{gpus[0]};
t1 = std::chrono::high_resolution_clock::now();
auto comm = preview::spmd::make_communicator<preview::spmd::backend::ccl>(
queue, executorNum, rank, kvs);
t2 = std::chrono::high_resolution_clock::now();
duration =
(float)std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1)
.count();
return comm;
}
2 changes: 0 additions & 2 deletions mllib-dal/src/main/native/GPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <jni.h>
#include <oneapi/ccl.hpp>

#include "Communicator.hpp"

sycl::queue getAssignedGPU(const ComputeDevice device, jint *gpu_indices);

sycl::queue getQueue(const ComputeDevice device);
Expand Down
10 changes: 3 additions & 7 deletions mllib-dal/src/main/native/Profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class Profiler {

void startProfile(std::string s = "") {
action = s;
logger::println(logger::INFO, "%s (native): start %s", subject.c_str(),
action.c_str());
logger::println(logger::INFO, "%s (native): start %s", subject.c_str(), action.c_str());
startTime = std::chrono::high_resolution_clock::now();
}

Expand All @@ -21,14 +20,11 @@ class Profiler {
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
end_time - startTime)
.count();
logger::println(logger::INFO, "%s (native): start %s took %f secs",
subject.c_str(), action.c_str(),
(float)duration / 1000);
logger::println(logger::INFO, "%s (native): start %s took %f secs", subject.c_str(), action.c_str(), (float)duration / 1000);
}

void println(std::string msg) {
logger::println(logger::INFO, "%s (native): %s", subject.c_str(),
msg.c_str());
logger::println(logger::INFO, "%s (native): %s", subject.c_str(), msg.c_str());
}

private:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 358cd89

Please sign in to comment.