Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
protect crash if it's a CPU SYCL device
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyu-intel committed Jun 4, 2024
1 parent 0262185 commit d80524b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
34 changes: 21 additions & 13 deletions bestla/bestla/sycl/sycl_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,29 @@ class SyclDevice {

double getGlobalMemSizeGB() { return double(getGlobalMemSize()) / 1e9; }

static inline bool is_cpu(const sycl::device& dev) {
return dev.get_info<sycl::info::device::device_type>() == sycl::info::device_type::cpu;
}

static inline bool is_gpu(const sycl::device& dev) {
return dev.get_info<sycl::info::device::device_type>() == sycl::info::device_type::gpu;
}

void print() {
std::cout << "Running on device: " << mQueue.get_device().get_info<sycl::info::device::name>() << "\n";
std::cout << "EU count:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_count>()
<< "\n"; // 448
std::cout << "EU count per subslice:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_count_per_subslice>() << "\n"; // 8
std::cout << "EU SIMD width:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_simd_width>()
<< "\n"; // 8
std::cout << "HW threads per EU:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_hw_threads_per_eu>() << "\n"; // 8
std::cout << "GPU slices:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_slices>()
<< "\n"; // 7
std::cout << "Subslice per slice:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_subslices_per_slice>() << "\n"; // 8
std::cout << "Global Memory size: " << getGlobalMemSizeGB() << "\n"; // 8
if (is_gpu(mQueue.get_device())) {
std::cout << "EU count:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_count>() << "\n";
std::cout << "EU count per subslice:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_count_per_subslice>() << "\n";
std::cout << "EU SIMD width:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_eu_simd_width>()
<< "\n";
std::cout << "HW threads per EU:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_hw_threads_per_eu>() << "\n";
std::cout << "GPU slices:" << mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_slices>() << "\n";
std::cout << "Subslice per slice:"
<< mQueue.get_device().get_info<sycl::info::device::ext_intel_gpu_subslices_per_slice>() << "\n";
}
std::cout << "Global Memory size: " << getGlobalMemSizeGB() << "\n";
}
sycl::queue mQueue;
};
Expand Down
4 changes: 2 additions & 2 deletions neural_speed/models/model_utils/model_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,8 @@ struct model_context* model_init_from_file(const char* path_model, struct model_
ctx->device = bestla_create_device(false);
ctx->device_queue = bestla_get_device_queue(ctx->device);
auto memsize = bestla_device_gmem_size(ctx->device);
size_t constexpr Reserve = size_t(1000) << 20;
ctx->device_buffer_size = memsize - Reserve;
size_t constexpr Reserve = size_t(4000) << 20;
ctx->device_buffer_size = std::min(Reserve, memsize);
ctx->device_buffer = bestla_device_malloc(ctx->device_buffer_size, ctx->device);
ctx->device_buffer_offs = 0;
#endif
Expand Down

0 comments on commit d80524b

Please sign in to comment.