Skip to content

Commit

Permalink
ggml: update ggml submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Oct 8, 2024
1 parent eb8d7b7 commit 9a6be60
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
8 changes: 4 additions & 4 deletions fundamentals/ggml/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CC = gcc
CC = g++
CXX = g++
CFLAGS = -g -Wall -Iggml/include -Iggml/src/ -Wno-unused-variable
LDFLAGS = -Lggml/build/src/
Expand Down Expand Up @@ -39,7 +39,7 @@ all: $(TARGETS_C)
ggml-quants: CFLAGS += -Iggml/src -Iggml/include/ggml

$(TARGETS_C): % : $(SRCDIR)/%.c | bindir
$(CC) $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/$@ $< \
$(CXX) $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/$@ $< \
$(WHOLE_ARCHIVE) \
-lm $(CUDA_FLAGS) $(VULKAN_FLAGS)

Expand All @@ -51,12 +51,12 @@ $(TARGETS_CPP): % : $(SRCDIR)/%.cpp | bindir
.PHONY: pre-quants
pre-quants: CFLAGS += -Iggml/src -Iggml/include/ggml
pre-quants:
$(CC) -E $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/quants.pre $(SRCDIR)/quants.c
$(CXX) -E $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/quants.pre $(SRCDIR)/quants.c

.PHONY: pre-ggml.c
pre-ggml.c: CFLAGS += -Iggml/src -Iggml/include/ggml
pre-ggml.c:
$(CC) -E $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/ggml.c.pre ggml/src/ggml.c
$(CXX) -E $(CFLAGS) $(LDFLAGS) -o ${BINDIR}/ggml.c.pre ggml/src/ggml.c

#.PHONY: backend-cuda
backend-cuda: CUDA_FLAGS := -L${CUDA_DIR} -lcuda -lcublas -lculibos -lcudart -lcublasLt
Expand Down
2 changes: 1 addition & 1 deletion fundamentals/ggml/ggml
Submodule ggml updated 58 files
+1 −1 Package.swift
+18 −86 README.md
+0 −160 build.zig
+4 −0 examples/CMakeLists.txt
+2 −7 examples/gpt-2/main-backend.cpp
+2 −6 examples/gpt-2/main-batched.cpp
+2 −3 examples/gpt-2/main-sched.cpp
+109 −77 examples/mnist/mnist-common.cpp
+83 −17 examples/mnist/mnist-common.h
+9 −14 examples/mnist/mnist-eval.cpp
+8 −9 examples/mnist/mnist-train.cpp
+7 −0 examples/perf-metal/CMakeLists.txt
+152 −0 examples/perf-metal/perf-metal.cpp
+2 −7 examples/simple/simple-backend.cpp
+1 −1 include/ggml-alloc.h
+144 −62 include/ggml-backend.h
+3 −3 include/ggml-blas.h
+9 −20 include/ggml-cann.h
+16 −16 include/ggml-cuda.h
+4 −9 include/ggml-metal.h
+5 −5 include/ggml-rpc.h
+8 −8 include/ggml-sycl.h
+7 −7 include/ggml-vulkan.h
+40 −39 include/ggml.h
+2 −2 scripts/sync-llama-am.sh
+1 −1 scripts/sync-llama.last
+1 −1 scripts/sync-llama.sh
+2 −2 scripts/sync-whisper-am.sh
+1 −1 scripts/sync-whisper.last
+1 −1 scripts/sync-whisper.sh
+18 −3 src/CMakeLists.txt
+152 −71 src/ggml-backend-impl.h
+537 −271 src/ggml-backend.cpp
+8 −10 src/ggml-blas.cpp
+67 −177 src/ggml-cann.cpp
+394 −255 src/ggml-cuda.cu
+79 −0 src/ggml-cuda/argmax.cu
+3 −0 src/ggml-cuda/argmax.cuh
+12 −0 src/ggml-cuda/common.cuh
+64 −0 src/ggml-cuda/count-equal.cu
+5 −0 src/ggml-cuda/count-equal.cuh
+1 −1 src/ggml-cuda/fattn-tile-f16.cu
+3 −3 src/ggml-cuda/fattn-vec-f16.cuh
+15 −0 src/ggml-impl.h
+2 −23 src/ggml-kompute.cpp
+1,960 −1,904 src/ggml-metal.m
+26 −27 src/ggml-rpc.cpp
+45 −62 src/ggml-sycl.cpp
+8 −8 src/ggml-sycl/dequantize.hpp
+215 −267 src/ggml-vulkan.cpp
+247 −78 src/ggml.c
+0 −10 tests/CMakeLists.txt
+0 −82 tests/test-backend-buffer.cpp
+91 −13 tests/test-backend-ops.cpp
+2 −11 tests/test-conv-transpose-1d.cpp
+2 −7 tests/test-conv1d.cpp
+2 −7 tests/test-conv2d.cpp
+0 −5 tests/test-mul-mat.cpp
8 changes: 4 additions & 4 deletions fundamentals/ggml/src/backend-schedular.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ int main(int argc, char **argv) {
}

// The following will call ggml_backend_registry_init
size_t count = ggml_backend_reg_get_count();
size_t count = ggml_backend_reg_count();
printf("Number of backends registered: %ld\n", count);
for (size_t i = 0; i < count; i++) {
printf("backend %ld name: %s\n", i, ggml_backend_reg_get_name(i));
printf("backend %ld name: %s\n", i, ggml_backend_dev_name(ggml_backend_dev_get(i)));
}

ggml_backend_t cpu_backend = ggml_backend_reg_init_backend_from_str("CPU");
ggml_backend_t cpu_backend = ggml_backend_init_by_name("CPU", NULL);
if (cpu_backend != NULL) {
ggml_backend_buffer_t buffer = ggml_backend_alloc_buffer(cpu_backend, 10*4);
print_backend_info(buffer, ctx);
ggml_backend_free(cpu_backend);
}

ggml_backend_t cuda_backend = ggml_backend_reg_init_backend_from_str("CUDA0");
ggml_backend_t cuda_backend = ggml_backend_init_by_name("CUDA0", NULL);
if (cuda_backend != NULL) {
ggml_backend_buffer_t buffer = ggml_backend_alloc_buffer(cuda_backend, 10*4);
print_backend_info(buffer, ctx);
Expand Down
11 changes: 4 additions & 7 deletions fundamentals/ggml/src/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,30 @@ int main(int argc, char **argv) {
struct ggml_context* ctx = ggml_init(params);
struct ggml_tensor* x = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 10);
ggml_set_name(x, "x");
printf("x backend type (0=CPU, 10=GPU): %d\n", x->backend);
if (x->buffer == NULL) {
printf("x backend buffer is NULL\n");
} else {
printf("x backend buffer: %s\n", ggml_backend_buffer_name(x->buffer));
}

// The following will call ggml_backend_registry_init
size_t count = ggml_backend_reg_get_count();
size_t count = ggml_backend_reg_count();
printf("Number of backends registered: %ld\n", count);
for (size_t i = 0; i < count; i++) {
printf("backend %ld name: %s\n", i, ggml_backend_reg_get_name(i));
printf("backend %ld name: %s\n", i, ggml_backend_dev_name(ggml_backend_dev_get(i)));
}

ggml_backend_t cpu_backend = ggml_backend_reg_init_backend_from_str("CPU");
ggml_backend_t cpu_backend = ggml_backend_init_by_name("CPU", NULL);
if (cpu_backend != NULL) {
ggml_backend_buffer_t buffer = ggml_backend_alloc_buffer(cpu_backend, 10*4);
print_backend_info(buffer, ctx);
ggml_backend_free(cpu_backend);
}

ggml_backend_t cuda_backend = ggml_backend_reg_init_backend_from_str("CUDA0");
ggml_backend_t cuda_backend = ggml_backend_init_by_name("CUDA0", NULL);
if (cuda_backend != NULL) {
ggml_backend_buffer_t buffer = ggml_backend_alloc_buffer(cuda_backend, 10*4);
print_backend_info(buffer, ctx);
printf("x backend type (%d=CPU, %d=GPU): %d\n", GGML_BACKEND_TYPE_CPU, GGML_BACKEND_TYPE_GPU, x->backend);
if (x->buffer != NULL) {
printf("x backend buffer: %s\n", ggml_backend_buffer_name(x->buffer));
}
Expand All @@ -67,7 +65,6 @@ int main(int argc, char **argv) {

// The following will copy the data from the host to the device.
ggml_backend_tensor_set(x, data, 0, 10);
printf("x backend type (%d=CPU, %d=GPU): %d\n", GGML_BACKEND_TYPE_CPU, GGML_BACKEND_TYPE_GPU, x->backend);
ggml_backend_free(cuda_backend);
}

Expand Down

0 comments on commit 9a6be60

Please sign in to comment.