Skip to content

Commit

Permalink
fix for multiple cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo Zhang authored and Neo Zhang committed Jul 13, 2024
1 parent aeaed61 commit a4c8edc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 15 additions & 19 deletions ggml/src/ggml-sycl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,7 @@ void sycl_device_mgr::detect_all_sycl_device_list() try {
int device_count = dpct::dev_mgr::instance().device_count();

for (int id = 0; id < device_count; id++) {
sycl::device device = dpct::dev_mgr::instance().get_device(id);
device_ids.push_back(id);
devices.push_back(device);
dpct::device_info prop;
dpct::get_device_info(prop, device);
work_group_sizes.push_back(prop.get_max_work_group_size());
max_compute_units.push_back(prop.get_max_compute_units());
hw_familys.push_back(get_device_family(&device));
add_device_info(id);
}
return;
} catch (sycl::exception const &exc) {
Expand Down Expand Up @@ -343,13 +336,7 @@ void sycl_device_mgr::detect_sycl_visible_device_list() try {
}
std::cerr << std::endl;
}
sycl::device device = dpct::dev_mgr::instance().get_device(id);
device_ids.push_back(id);
devices.push_back(device);
dpct::device_info prop;
dpct::get_device_info(prop, device);
work_group_sizes.push_back(prop.get_max_work_group_size());
max_compute_units.push_back(prop.get_max_compute_units());
add_device_info(id);
}
return;
} catch (sycl::exception const &exc) {
Expand Down Expand Up @@ -382,10 +369,7 @@ void sycl_device_mgr::detect_sycl_gpu_list_with_max_cu() try {
dpct::get_device_info(prop, device);
if (local_max_compute_units == prop.get_max_compute_units() &&
is_ext_oneapi_device(device)) {
device_ids.push_back(id);
devices.push_back(device);
work_group_sizes.push_back(prop.get_max_work_group_size());
max_compute_units.push_back(prop.get_max_compute_units());
add_device_info(id);
}
}
return;
Expand All @@ -405,6 +389,18 @@ bool sycl_device_mgr::is_ext_oneapi_device(const sycl::device &dev) {
return true;
return false;
}

void sycl_device_mgr::add_device_info(int id) {
sycl::device device = dpct::dev_mgr::instance().get_device(id);
device_ids.push_back(id);
devices.push_back(device);
dpct::device_info prop;
dpct::get_device_info(prop, device);
work_group_sizes.push_back(prop.get_max_work_group_size());
max_compute_units.push_back(prop.get_max_compute_units());
hw_familys.push_back(get_device_family(&device));
}

//--sycl_device_mgr--

//--ggml_sycl_device_info--
Expand Down
2 changes: 2 additions & 0 deletions ggml/src/ggml-sycl/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ inline dpct::err0 ggml_sycl_set_device(const int device_id) try {
std::exit(1);
}


class sycl_device_mgr {
public:
std::vector<int> device_ids;
Expand Down Expand Up @@ -211,6 +212,7 @@ class sycl_device_mgr {
void detect_sycl_gpu_list_with_max_cu();
int get_device_count();
bool is_ext_oneapi_device(const sycl::device &dev);
void add_device_info(int id);
};


Expand Down

0 comments on commit a4c8edc

Please sign in to comment.