Skip to content

Commit 0ec4dab

Browse files
committed
fixed break and asssion from select; try fix cuda link error
1 parent 2193ab6 commit 0ec4dab

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

ggml-cuda.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct ggml_tensor_extra_gpu {
1515
void ggml_init_cublas(void);
1616
void ggml_cuda_set_tensor_split(const float * tensor_split);
1717

18+
bool ggml_cuda_is_gpu_offloading(struct ggml_tensor * tensor);
1819
void ggml_cuda_mul(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
19-
bool ggml_cuda_is_gpu_offloading(const struct ggml_tensor * src0);
2020
size_t ggml_cuda_mul_mat_get_wsize(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
2121
void ggml_cuda_mul_mat(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst, void * wdata, size_t wsize);
2222

ggml-opencl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ static void ggml_cl_mul_mat_q_f32(const ggml_tensor * src0, const ggml_tensor *
15891589
}
15901590
}
15911591

1592-
bool ggml_cl_is_gpu_offloading(struct ggml_tensor * tensor) {
1592+
bool ggml_cl_is_gpu_offloading(const struct ggml_tensor * tensor) {
15931593
GGML_ASSERT(tensor);
15941594
return (tensor->src0 && tensor->src0->backend == GGML_BACKEND_GPU) ||
15951595
(tensor->src1 && tensor->src1->backend == GGML_BACKEND_GPU);

ggml-opencl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extern "C" {
88

99
void ggml_cl_init(void);
1010

11+
bool ggml_cl_is_gpu_offloading(const struct ggml_tensor * tensor);
1112
void ggml_cl_mul(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
12-
bool ggml_cl_is_gpu_offloading(struct ggml_tensor * tensor);
1313
size_t ggml_cl_mul_mat_get_wsize(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
1414
void ggml_cl_mul_mat(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst, void * wdata, size_t wsize);
1515

ggml-threading.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int sched_yield(void) {
142142
#endif
143143

144144
struct ggml_perf_stats {
145-
int runs;
145+
atomic_int runs;
146146

147147
// total cycles
148148
atomic_int cycles;
@@ -211,9 +211,9 @@ static inline void ggml_spin_unlock(volatile atomic_flag *obj) {
211211

212212
static inline void ggml_perf_collect(struct ggml_perf_stats *st, int64_t c0,
213213
int64_t t0) {
214-
st->runs++;
215-
st->cycles += (ggml_cycles() - c0);
216-
st->time_us += (ggml_time_us() - t0);
214+
atomic_fetch_add(&st->runs, 1);
215+
atomic_fetch_add(&st->cycles, (int)(ggml_cycles() - c0));
216+
atomic_fetch_add(&st->time_us, (int)(ggml_time_us() - t0));
217217
}
218218

219219
// A worker thread goes cond waiting.

ggml.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15468,7 +15468,7 @@ struct ggml_cgraph ggml_build_backward(struct ggml_context * ctx, struct ggml_cg
1546815468
// ---- task profiles ----
1546915469

1547015470
// Check the type and memeory layout for mul_mat on blas(CPU BLAS)
15471-
static bool ggml_mul_mat_check_type_mem(struct ggml_tensor *tensor) {
15471+
static bool ggml_mul_mat_check_type_mem(const struct ggml_tensor *tensor) {
1547215472
enum ggml_type src0_t = tensor->src0->type;
1547315473
enum ggml_type src1_t = tensor->src1->type;
1547415474

@@ -15669,6 +15669,8 @@ int ggml_get_task_profiles(
1566915669
p[0].stages[0].valid = true;
1567015670
p[0].stages[1].valid = true;
1567115671
p[0].stages[1].parallel = true;
15672+
} else {
15673+
GGML_ASSERT(false);
1567215674
}
1567315675
} break;
1567415676
case GGML_OP_SCALE: {
@@ -15717,7 +15719,7 @@ int ggml_get_task_profiles(
1571715719
case GGML_OP_FLASH_FF: {
1571815720
p[0].stages[1].valid = true;
1571915721
p[0].stages[1].parallel = true;
15720-
}
15722+
} break;
1572115723
case GGML_OP_FLASH_ATTN_BACK: {
1572215724
p[0].stages[0].valid = true;
1572315725
p[0].stages[1].valid = true;
@@ -15727,11 +15729,12 @@ int ggml_get_task_profiles(
1572715729
case GGML_OP_MAP_BINARY: {
1572815730
p[0].stages[1].valid = true;
1572915731
} break;
15730-
case GGML_OP_CROSS_ENTROPY_LOSS:
15732+
case GGML_OP_CROSS_ENTROPY_LOSS: {
1573115733
p[0].stages[0].valid = true;
1573215734
p[0].stages[1].valid = true;
1573315735
p[0].stages[1].parallel = true;
1573415736
p[0].stages[2].valid = true;
15737+
} break;
1573515738
case GGML_OP_CROSS_ENTROPY_LOSS_BACK: {
1573615739
p[0].stages[1].valid = true;
1573715740
p[0].stages[1].parallel = true;
@@ -15764,6 +15767,8 @@ int ggml_get_task_profiles(
1576415767
p[i].stages[0].parallel = true;
1576515768
p[i].stages[1].valid = true;
1576615769
p[i].stages[1].wait = true;
15770+
} else {
15771+
GGML_ASSERT(false);
1576715772
}
1576815773
++n_profiles;
1576915774
}

0 commit comments

Comments
 (0)