Skip to content

Commit 27c3f29

Browse files
committed
backup
1 parent e1b7913 commit 27c3f29

File tree

8 files changed

+279
-311
lines changed

8 files changed

+279
-311
lines changed

ggml-sycl.cpp

Lines changed: 269 additions & 259 deletions
Large diffs are not rendered by default.

ggml-sycl/common.hpp

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ static int g_work_group_size = 0;
7979
#endif
8080

8181
typedef sycl::queue *queue_ptr;
82-
typedef sycl::handler *handle_ptr;
8382

8483
enum ggml_sycl_backend_gpu_mode {
8584
SYCL_UNSET_GPU_MODE = -1,
@@ -313,13 +312,12 @@ class sycl_gpu_mgr {
313312
};
314313

315314
static sycl_gpu_mgr* g_sycl_gpu_mgr = new sycl_gpu_mgr(0);
316-
static int g_device_count = -1;
317315
static int g_all_sycl_device_count = -1;
318316
static int g_main_device = -1;
319317
static int g_main_device_id = -1;
320318
static bool g_ggml_backend_sycl_buffer_type_initialized = false;
321319

322-
static std::array<float, SYCL_MAX_DEVICES> g_default_tensor_split = {};
320+
static std::array<float, GGML_SYCL_MAX_DEVICES> g_default_tensor_split = {};
323321

324322
static float g_tensor_split[GGML_SYCL_MAX_DEVICES] = {0};
325323

@@ -341,25 +339,6 @@ int get_main_device();
341339
(void)bad_arch; // suppress unused function warning
342340
}
343341

344-
/*
345-
device_index: device index from 0 to n (continue numbers).
346-
It is used for device select/set in SYCL backend internal data structure.
347-
*/
348-
inline void check_allow_gpu_index(const int device_index) {
349-
if (device_index >= g_device_count) {
350-
char error_buf[256];
351-
snprintf(
352-
error_buf,
353-
sizeof(error_buf),
354-
"%s error: device_index:%d is out of range: [0-%d]",
355-
__func__,
356-
device_index,
357-
g_device_count - 1);
358-
fprintf(stderr, "%s\n", error_buf);
359-
assert(false);
360-
}
361-
}
362-
363342
/*
364343
device_id: device ID is shown by ggml_backend_sycl_print_sycl_devices().
365344
It is only used to set current working device.
@@ -487,30 +466,16 @@ struct ggml_backend_sycl_context {
487466
std::string name;
488467

489468
queue_ptr qptrs[GGML_SYCL_MAX_DEVICES][GGML_SYCL_MAX_STREAMS] = { { nullptr } };
490-
static sycl::handler * sycl_handles[GGML_SYCL_MAX_DEVICES] = {nullptr};
491469

492470
explicit ggml_backend_sycl_context(int device) :
493471
device(device),
494472
name(GGML_SYCL_NAME + std::to_string(device)) {
495473
}
496474

497-
~ggml_backend_sycl_context() {
498-
for (int i = 0; i < GGML_SYCL_MAX_DEVICES; ++i) {
499-
for (int j = 0; j < GGML_SYCL_MAX_STREAMS; ++j) {
500-
if (qptrs[i][j] != nullptr) {
501-
SYCL_CHECK(free(qptrs[i][j]));
502-
}
503-
}
504-
if (cublas_handles[i] != nullptr) {
505-
SYCL_CHECK(free(sycl_handles[i]));
506-
}
507-
}
508-
}
509-
510475
queue_ptr stream(int device, int stream) {
511476
if (qptrs[device][stream] == nullptr) {
512-
SYCL_CHECK(dpct::get_current_device().create_queue(
513-
g_sycl_gpu_mgr->get_co_ctx(), dpct::get_current_device())));
477+
qptrs[device][stream] = (dpct::get_current_device().create_queue(
478+
g_sycl_gpu_mgr->get_co_ctx(), dpct::get_current_device()));
514479
}
515480
return qptrs[device][stream];
516481
}
@@ -519,27 +484,14 @@ struct ggml_backend_sycl_context {
519484
return stream(device, 0);
520485
}
521486

522-
handle_ptr sycl_handle(int device) {
523-
if (sycl_handles[device] == nullptr) {
524-
const dpct::queue_ptr stream = qptrs[device][0];
525-
// create sycl handle
526-
SYCL_CHECK(CHECK_TRY_ERROR(sycl_handles[device] = stream));
527-
}
528-
return sycl_handles[device];
529-
}
530-
531-
handle_ptr sycl_handle() {
532-
return sycl_handle(device);
533-
}
534-
535487
// pool
536488
std::unique_ptr<ggml_sycl_pool> pools[GGML_SYCL_MAX_DEVICES];
537489

538490
static std::unique_ptr<ggml_sycl_pool> new_pool_for_device(queue_ptr qptr, int device);
539491

540492
ggml_sycl_pool & pool(int device) {
541493
if (pools[device] == nullptr) {
542-
pools[device] = new_pool_for_device(qptrs[device][0], device);
494+
pools[device] = new_pool_for_device(stream(device,0), device);
543495
}
544496
return *pools[device];
545497
}

ggml-sycl/dmmv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ static void dequantize_mul_mat_vec_q6_K_sycl(const void *vx, const float *y,
943943
}
944944

945945
void ggml_sycl_op_dequantize_mul_mat_vec(
946+
ggml_backend_sycl_context & ctx,
946947
const ggml_tensor *src0, const ggml_tensor *src1, ggml_tensor *dst,
947948
const char *src0_dd_i, const float *src1_ddf_i, const char *src1_ddq_i,
948949
float *dst_dd_i, const int64_t row_low, const int64_t row_high,

ggml-sycl/dmmv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
void ggml_sycl_op_dequantize_mul_mat_vec(
20+
ggml_backend_sycl_context & ctx,
2021
const ggml_tensor *src0, const ggml_tensor *src1, ggml_tensor *dst,
2122
const char *src0_dd_i, const float *src1_ddf_i, const char *src1_ddq_i,
2223
float *dst_dd_i, const int64_t row_low, const int64_t row_high,

ggml-sycl/mmq.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,6 +2960,7 @@ catch (sycl::exception const &exc) {
29602960
}
29612961

29622962
void ggml_sycl_op_mul_mat_q(
2963+
ggml_backend_sycl_context & ctx,
29632964
const ggml_tensor *src0, const ggml_tensor *src1, ggml_tensor *dst,
29642965
const char *src0_dd_i, const float *src1_ddf_i, const char *src1_ddq_i,
29652966
float *dst_dd_i, const int64_t row_low, const int64_t row_high,

ggml-sycl/mmq.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "common.hpp"
1717

1818
void ggml_sycl_op_mul_mat_q(
19+
ggml_backend_sycl_context & ctx,
1920
const ggml_tensor* src0,
2021
const ggml_tensor* src1,
2122
ggml_tensor* dst,

ggml-sycl/mmvq.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ static void mul_mat_vec_iq4_xs_q8_1_sycl(const void *vx, const void *vy,
932932
}
933933

934934
void ggml_sycl_op_mul_mat_vec_q(
935+
ggml_backend_sycl_context & ctx,
935936
const ggml_tensor *src0, const ggml_tensor *src1, ggml_tensor *dst,
936937
const char *src0_dd_i, const float *src1_ddf_i, const char *src1_ddq_i,
937938
float *dst_dd_i, const int64_t row_low, const int64_t row_high,

ggml-sycl/mmvq.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
void ggml_sycl_op_mul_mat_vec_q(
20+
ggml_backend_sycl_context & ctx,
2021
const ggml_tensor *src0, const ggml_tensor *src1, ggml_tensor *dst,
2122
const char *src0_dd_i, const float *src1_ddf_i, const char *src1_ddq_i,
2223
float *dst_dd_i, const int64_t row_low, const int64_t row_high,

0 commit comments

Comments
 (0)