@@ -342,13 +342,9 @@ else
342
342
MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
343
343
endif
344
344
345
- ifndef LLAMA_NO_K_QUANTS
346
- MK_CPPFLAGS += -DGGML_USE_K_QUANTS
347
- OBJS += k_quants.o
348
345
ifdef LLAMA_QKK_64
349
346
MK_CPPFLAGS += -DGGML_QKK_64
350
347
endif
351
- endif
352
348
353
349
ifndef LLAMA_NO_ACCELERATE
354
350
# Mac OS - include Accelerate framework.
@@ -365,7 +361,7 @@ ifdef LLAMA_MPI
365
361
MK_CPPFLAGS += -DGGML_USE_MPI
366
362
MK_CFLAGS += -Wno-cast-qual
367
363
MK_CXXFLAGS += -Wno-cast-qual
368
- OBJS += ggml-mpi.o
364
+ OBJS += ggml-mpi.o
369
365
endif # LLAMA_MPI
370
366
371
367
ifdef LLAMA_OPENBLAS
@@ -382,7 +378,7 @@ endif # LLAMA_BLIS
382
378
ifdef LLAMA_CUBLAS
383
379
MK_CPPFLAGS += -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I$(CUDA_PATH)/targets/x86_64-linux/include
384
380
MK_LDFLAGS += -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L$(CUDA_PATH)/targets/x86_64-linux/lib
385
- OBJS += ggml-cuda.o
381
+ OBJS += ggml-cuda.o
386
382
NVCCFLAGS = --forward-unknown-to-host-compiler -use_fast_math
387
383
ifdef LLAMA_CUDA_NVCC
388
384
NVCC = $(LLAMA_CUDA_NVCC)
@@ -397,6 +393,9 @@ endif # CUDA_DOCKER_ARCH
397
393
ifdef LLAMA_CUDA_FORCE_DMMV
398
394
NVCCFLAGS += -DGGML_CUDA_FORCE_DMMV
399
395
endif # LLAMA_CUDA_FORCE_DMMV
396
+ ifdef LLAMA_CUDA_FORCE_MMQ
397
+ NVCCFLAGS += -DGGML_CUDA_FORCE_MMQ
398
+ endif # LLAMA_CUDA_FORCE_MMQ
400
399
ifdef LLAMA_CUDA_DMMV_X
401
400
NVCCFLAGS += -DGGML_CUDA_DMMV_X=$(LLAMA_CUDA_DMMV_X)
402
401
else
@@ -494,11 +493,6 @@ ggml-mpi.o: ggml-mpi.c ggml-mpi.h
494
493
$(CC ) $(CFLAGS ) -c $< -o $@
495
494
endif # LLAMA_MPI
496
495
497
- ifndef LLAMA_NO_K_QUANTS
498
- k_quants.o : k_quants.c k_quants.h
499
- $(CC ) $(CFLAGS ) -c $< -o $@
500
- endif # LLAMA_NO_K_QUANTS
501
-
502
496
# combine build flags with cmdline overrides
503
497
override CFLAGS := $(MK_CPPFLAGS ) $(CPPFLAGS ) $(MK_CFLAGS ) $(CFLAGS )
504
498
override CXXFLAGS := $(MK_CPPFLAGS ) $(CPPFLAGS ) $(MK_CXXFLAGS ) $(CXXFLAGS )
@@ -539,13 +533,16 @@ ggml-alloc.o: ggml-alloc.c ggml.h ggml-alloc.h
539
533
ggml-backend.o : ggml-backend.c ggml.h ggml-backend.h
540
534
$(CC ) $(CFLAGS ) -c $< -o $@
541
535
542
- OBJS += ggml-alloc.o ggml-backend.o
536
+ ggml-quants.o : ggml-quants.c ggml.h ggml-quants.h
537
+ $(CC ) $(CFLAGS ) -c $< -o $@
538
+
539
+ OBJS += ggml-alloc.o ggml-backend.o ggml-quants.o
543
540
544
541
llama.o : llama.cpp ggml.h ggml-alloc.h ggml-backend.h ggml-cuda.h ggml-metal.h llama.h
545
542
$(CXX ) $(CXXFLAGS ) -c $< -o $@
546
543
547
- COMMON_H_DEPS = common/common.h common/sampling.h build-info.h common/log.h
548
- COMMON_DEPS = $( COMMON_H_DEPS ) common.o sampling.o grammar-parser.o
544
+ COMMON_H_DEPS = common/common.h common/sampling.h common/log.h
545
+ COMMON_DEPS = common.o sampling.o grammar-parser.o build-info .o
549
546
550
547
common.o : common/common.cpp $(COMMON_H_DEPS )
551
548
$(CXX ) $(CXXFLAGS ) -c $< -o $@
@@ -566,46 +563,46 @@ libllama.so: llama.o ggml.o $(OBJS)
566
563
$(CXX ) $(CXXFLAGS ) -shared -fPIC -o $@ $^ $(LDFLAGS )
567
564
568
565
clean :
569
- rm -vrf * .o tests/* .o * .so * .dll benchmark-matmult build-info.h * .dot $(COV_TARGETS ) $(BUILD_TARGETS ) $(TEST_TARGETS )
566
+ rm -vrf * .o tests/* .o * .so * .dll benchmark-matmult common/ build-info.cpp * .dot $(COV_TARGETS ) $(BUILD_TARGETS ) $(TEST_TARGETS )
570
567
571
568
#
572
569
# Examples
573
570
#
574
571
575
- main : examples/main/main.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) console.o grammar-parser.o $(OBJS )
572
+ main : examples/main/main.cpp ggml.o llama.o $(COMMON_DEPS ) console.o grammar-parser.o $(OBJS )
576
573
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
577
574
@echo
578
575
@echo ' ==== Run ./main -h for help. ===='
579
576
@echo
580
577
581
- infill : examples/infill/infill.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) console.o grammar-parser.o $(OBJS )
578
+ infill : examples/infill/infill.cpp ggml.o llama.o $(COMMON_DEPS ) console.o grammar-parser.o $(OBJS )
582
579
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
583
580
584
- simple : examples/simple/simple.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
581
+ simple : examples/simple/simple.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
585
582
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
586
583
587
- batched : examples/batched/batched.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
584
+ batched : examples/batched/batched.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
588
585
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
589
586
590
- batched-bench : examples/batched-bench/batched-bench.cpp build-info.h ggml.o llama.o common.o $(OBJS )
587
+ batched-bench : examples/batched-bench/batched-bench.cpp build-info.o ggml.o llama.o common.o $(OBJS )
591
588
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
592
589
593
- quantize : examples/quantize/quantize.cpp build-info.h ggml.o llama.o $(OBJS )
590
+ quantize : examples/quantize/quantize.cpp build-info.o ggml.o llama.o $(OBJS )
594
591
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
595
592
596
- quantize-stats : examples/quantize-stats/quantize-stats.cpp build-info.h ggml.o llama.o $(OBJS )
593
+ quantize-stats : examples/quantize-stats/quantize-stats.cpp build-info.o ggml.o llama.o $(OBJS )
597
594
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
598
595
599
- perplexity : examples/perplexity/perplexity.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
596
+ perplexity : examples/perplexity/perplexity.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
600
597
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
601
598
602
- embedding : examples/embedding/embedding.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
599
+ embedding : examples/embedding/embedding.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
603
600
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
604
601
605
- save-load-state : examples/save-load-state/save-load-state.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
602
+ save-load-state : examples/save-load-state/save-load-state.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
606
603
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
607
604
608
- server : examples/server/server.cpp examples/server/httplib.h examples/server/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h build-info.h ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
605
+ server : examples/server/server.cpp examples/server/httplib.h examples/server/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
609
606
$(CXX ) $(CXXFLAGS ) -Iexamples/server $(filter-out % .h,$(filter-out % .hpp,$^ ) ) -o $@ $(LDFLAGS ) $(LWINSOCK2 ) -Wno-cast-qual
610
607
611
608
gguf : examples/gguf/gguf.cpp ggml.o llama.o $(OBJS )
@@ -617,7 +614,7 @@ train-text-from-scratch: examples/train-text-from-scratch/train-text-from-scratc
617
614
convert-llama2c-to-ggml : examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp ggml.o llama.o $(OBJS )
618
615
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
619
616
620
- llama-bench : examples/llama-bench/llama-bench.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
617
+ llama-bench : examples/llama-bench/llama-bench.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
621
618
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
622
619
623
620
llava : examples/llava/llava.cpp examples/llava/llava-utils.h examples/llava/clip.cpp examples/llava/clip.h common/stb_image.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
@@ -626,19 +623,19 @@ llava: examples/llava/llava.cpp examples/llava/llava-utils.h examples/llava/clip
626
623
baby-llama : examples/baby-llama/baby-llama.cpp ggml.o llama.o $(COMMON_DEPS ) train.o $(OBJS )
627
624
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
628
625
629
- beam-search : examples/beam-search/beam-search.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
626
+ beam-search : examples/beam-search/beam-search.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
630
627
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
631
628
632
- finetune : examples/finetune/finetune.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) train.o $(OBJS )
629
+ finetune : examples/finetune/finetune.cpp ggml.o llama.o $(COMMON_DEPS ) train.o $(OBJS )
633
630
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
634
631
635
- export-lora : examples/export-lora/export-lora.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
632
+ export-lora : examples/export-lora/export-lora.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
636
633
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
637
634
638
- speculative : examples/speculative/speculative.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
635
+ speculative : examples/speculative/speculative.cpp ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
639
636
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
640
637
641
- parallel : examples/parallel/parallel.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
638
+ parallel : examples/parallel/parallel.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
642
639
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
643
640
644
641
ifdef LLAMA_METAL
@@ -651,21 +648,24 @@ swift: examples/batched.swift
651
648
(cd examples/batched.swift; make build)
652
649
endif
653
650
654
- build-info.h : $(wildcard .git/index) scripts/build-info.sh
651
+ common/ build-info.cpp : $(wildcard .git/index) scripts/build-info.sh
655
652
@sh scripts/build-info.sh $(CC ) > $@ .tmp
656
653
@if ! cmp -s $@ .tmp $@ ; then \
657
654
mv $@ .tmp $@ ; \
658
655
else \
659
656
rm $@ .tmp; \
660
657
fi
661
658
659
+ build-info.o : common/build-info.cpp
660
+ $(CXX ) $(CXXFLAGS ) -c $(filter-out % .h,$^ ) -o $@
661
+
662
662
#
663
663
# Tests
664
664
#
665
665
666
666
tests : $(TEST_TARGETS )
667
667
668
- benchmark-matmult : examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS )
668
+ benchmark-matmult : examples/benchmark/benchmark-matmult.cpp build-info.o ggml.o $(OBJS )
669
669
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
670
670
671
671
run-benchmark-matmult : benchmark-matmult
@@ -679,40 +679,40 @@ vdot: pocs/vdot/vdot.cpp ggml.o $(OBJS)
679
679
q8dot : pocs/vdot/q8dot.cpp ggml.o $(OBJS )
680
680
$(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
681
681
682
- tests/test-llama-grammar : tests/test-llama-grammar.cpp build-info.h ggml.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
682
+ tests/test-llama-grammar : tests/test-llama-grammar.cpp ggml.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
683
683
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
684
684
685
- tests/test-grammar-parser : tests/test-grammar-parser.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
685
+ tests/test-grammar-parser : tests/test-grammar-parser.cpp ggml.o llama.o $(COMMON_DEPS ) grammar-parser.o $(OBJS )
686
686
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
687
687
688
- tests/test-double-float : tests/test-double-float.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
688
+ tests/test-double-float : tests/test-double-float.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
689
689
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
690
690
691
- tests/test-grad0 : tests/test-grad0.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
691
+ tests/test-grad0 : tests/test-grad0.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
692
692
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
693
693
694
- tests/test-opt : tests/test-opt.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
694
+ tests/test-opt : tests/test-opt.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
695
695
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
696
696
697
- tests/test-quantize-fns : tests/test-quantize-fns.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
697
+ tests/test-quantize-fns : tests/test-quantize-fns.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
698
698
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
699
699
700
- tests/test-quantize-perf : tests/test-quantize-perf.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
700
+ tests/test-quantize-perf : tests/test-quantize-perf.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
701
701
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
702
702
703
- tests/test-sampling : tests/test-sampling.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
703
+ tests/test-sampling : tests/test-sampling.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
704
704
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
705
705
706
- tests/test-tokenizer-0-falcon : tests/test-tokenizer-0-falcon.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
706
+ tests/test-tokenizer-0-falcon : tests/test-tokenizer-0-falcon.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
707
707
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
708
708
709
- tests/test-tokenizer-0-llama : tests/test-tokenizer-0-llama.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
709
+ tests/test-tokenizer-0-llama : tests/test-tokenizer-0-llama.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
710
710
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
711
711
712
- tests/test-tokenizer-1-bpe : tests/test-tokenizer-1-bpe.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
712
+ tests/test-tokenizer-1-bpe : tests/test-tokenizer-1-bpe.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
713
713
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
714
714
715
- tests/test-tokenizer-1-llama : tests/test-tokenizer-1-llama.cpp build-info.h ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
715
+ tests/test-tokenizer-1-llama : tests/test-tokenizer-1-llama.cpp ggml.o llama.o $(COMMON_DEPS ) $(OBJS )
716
716
$(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
717
717
718
718
tests/test-c.o : tests/test-c.c llama.h
0 commit comments