Skip to content

Commit

Permalink
fixed break and asssion from select; try fix cuda link error
Browse files Browse the repository at this point in the history
  • Loading branch information
mqy committed Jun 18, 2023
1 parent 2193ab6 commit 0ec4dab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ggml-cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct ggml_tensor_extra_gpu {
void ggml_init_cublas(void);
void ggml_cuda_set_tensor_split(const float * tensor_split);

bool ggml_cuda_is_gpu_offloading(struct ggml_tensor * tensor);
void ggml_cuda_mul(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
bool ggml_cuda_is_gpu_offloading(const struct ggml_tensor * src0);
size_t ggml_cuda_mul_mat_get_wsize(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
void ggml_cuda_mul_mat(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst, void * wdata, size_t wsize);

Expand Down
2 changes: 1 addition & 1 deletion ggml-opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ static void ggml_cl_mul_mat_q_f32(const ggml_tensor * src0, const ggml_tensor *
}
}

bool ggml_cl_is_gpu_offloading(struct ggml_tensor * tensor) {
bool ggml_cl_is_gpu_offloading(const struct ggml_tensor * tensor) {
GGML_ASSERT(tensor);
return (tensor->src0 && tensor->src0->backend == GGML_BACKEND_GPU) ||
(tensor->src1 && tensor->src1->backend == GGML_BACKEND_GPU);
Expand Down
2 changes: 1 addition & 1 deletion ggml-opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extern "C" {

void ggml_cl_init(void);

bool ggml_cl_is_gpu_offloading(const struct ggml_tensor * tensor);
void ggml_cl_mul(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
bool ggml_cl_is_gpu_offloading(struct ggml_tensor * tensor);
size_t ggml_cl_mul_mat_get_wsize(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst);
void ggml_cl_mul_mat(const struct ggml_tensor * src0, const struct ggml_tensor * src1, struct ggml_tensor * dst, void * wdata, size_t wsize);

Expand Down
8 changes: 4 additions & 4 deletions ggml-threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int sched_yield(void) {
#endif

struct ggml_perf_stats {
int runs;
atomic_int runs;

// total cycles
atomic_int cycles;
Expand Down Expand Up @@ -211,9 +211,9 @@ static inline void ggml_spin_unlock(volatile atomic_flag *obj) {

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

// A worker thread goes cond waiting.
Expand Down
11 changes: 8 additions & 3 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -15468,7 +15468,7 @@ struct ggml_cgraph ggml_build_backward(struct ggml_context * ctx, struct ggml_cg
// ---- task profiles ----

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

Expand Down Expand Up @@ -15669,6 +15669,8 @@ int ggml_get_task_profiles(
p[0].stages[0].valid = true;
p[0].stages[1].valid = true;
p[0].stages[1].parallel = true;
} else {
GGML_ASSERT(false);
}
} break;
case GGML_OP_SCALE: {
Expand Down Expand Up @@ -15717,7 +15719,7 @@ int ggml_get_task_profiles(
case GGML_OP_FLASH_FF: {
p[0].stages[1].valid = true;
p[0].stages[1].parallel = true;
}
} break;
case GGML_OP_FLASH_ATTN_BACK: {
p[0].stages[0].valid = true;
p[0].stages[1].valid = true;
Expand All @@ -15727,11 +15729,12 @@ int ggml_get_task_profiles(
case GGML_OP_MAP_BINARY: {
p[0].stages[1].valid = true;
} break;
case GGML_OP_CROSS_ENTROPY_LOSS:
case GGML_OP_CROSS_ENTROPY_LOSS: {
p[0].stages[0].valid = true;
p[0].stages[1].valid = true;
p[0].stages[1].parallel = true;
p[0].stages[2].valid = true;
} break;
case GGML_OP_CROSS_ENTROPY_LOSS_BACK: {
p[0].stages[1].valid = true;
p[0].stages[1].parallel = true;
Expand Down Expand Up @@ -15764,6 +15767,8 @@ int ggml_get_task_profiles(
p[i].stages[0].parallel = true;
p[i].stages[1].valid = true;
p[i].stages[1].wait = true;
} else {
GGML_ASSERT(false);
}
++n_profiles;
}
Expand Down

0 comments on commit 0ec4dab

Please sign in to comment.