Skip to content

Commit e6616cf

Browse files
authored
examples : add compiler version and target to build info (#2998)
1 parent 3aefaab commit e6616cf

File tree

21 files changed

+97
-51
lines changed

21 files changed

+97
-51
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,22 +499,22 @@ main: examples/main/main.cpp build-info.h ggml.
499499
@echo '==== Run ./main -h for help. ===='
500500
@echo
501501

502-
simple: examples/simple/simple.cpp build-info.h ggml.o llama.o common.o $(OBJS)
502+
simple: examples/simple/simple.cpp ggml.o llama.o common.o $(OBJS)
503503
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
504504

505-
quantize: examples/quantize/quantize.cpp build-info.h ggml.o llama.o $(OBJS)
505+
quantize: examples/quantize/quantize.cpp ggml.o llama.o $(OBJS)
506506
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
507507

508-
quantize-stats: examples/quantize-stats/quantize-stats.cpp build-info.h ggml.o llama.o $(OBJS)
508+
quantize-stats: examples/quantize-stats/quantize-stats.cpp ggml.o llama.o $(OBJS)
509509
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
510510

511-
perplexity: examples/perplexity/perplexity.cpp build-info.h ggml.o llama.o common.o $(OBJS)
511+
perplexity: examples/perplexity/perplexity.cpp ggml.o llama.o common.o $(OBJS)
512512
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
513513

514-
embedding: examples/embedding/embedding.cpp build-info.h ggml.o llama.o common.o $(OBJS)
514+
embedding: examples/embedding/embedding.cpp ggml.o llama.o common.o $(OBJS)
515515
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
516516

517-
save-load-state: examples/save-load-state/save-load-state.cpp build-info.h ggml.o llama.o common.o $(OBJS)
517+
save-load-state: examples/save-load-state/save-load-state.cpp ggml.o llama.o common.o $(OBJS)
518518
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
519519

520520
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 build-info.h ggml.o llama.o common.o grammar-parser.o $(OBJS)
@@ -554,7 +554,7 @@ metal: examples/metal/metal.cpp ggml.o $(OBJS)
554554
endif
555555

556556
build-info.h: $(wildcard .git/index) scripts/build-info.sh
557-
@sh scripts/build-info.sh > $@.tmp
557+
@sh scripts/build-info.sh $(CC) > $@.tmp
558558
@if ! cmp -s $@.tmp $@; then \
559559
mv $@.tmp $@; \
560560
else \
@@ -567,7 +567,7 @@ build-info.h: $(wildcard .git/index) scripts/build-info.sh
567567

568568
tests: $(TEST_TARGETS)
569569

570-
benchmark-matmult: examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS)
570+
benchmark-matmult: examples/benchmark/benchmark-matmult.cpp ggml.o $(OBJS)
571571
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
572572
./$@
573573

common/common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#pragma once
44

55
#include "llama.h"
6+
#include "build-info.h"
67

78
#define LOG_NO_FILE_LINE_FUNCTION
89
#include "log.h"
@@ -23,6 +24,11 @@
2324
#define die(msg) do { fputs("error: " msg "\n", stderr); exit(1); } while (0)
2425
#define die_fmt(fmt, ...) do { fprintf(stderr, "error: " fmt "\n", __VA_ARGS__); exit(1); } while (0)
2526

27+
#define print_build_info() do { \
28+
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT); \
29+
fprintf(stderr, "%s: built with %s for %s\n", __func__, BUILD_COMPILER, BUILD_TARGET); \
30+
} while(0)
31+
2632
//
2733
// CLI argument parsing
2834
//

examples/beam-search/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ add_executable(${TARGET} beam-search.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)
6-
if(TARGET BUILD_INFO)
7-
add_dependencies(${TARGET} BUILD_INFO)
8-
endif()

examples/beam-search/beam-search.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22
#include "llama.h"
3-
#include "build-info.h"
43

54
#include <cassert>
65
#include <cinttypes>

examples/benchmark/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
set(TARGET benchmark)
22
add_executable(${TARGET} benchmark-matmult.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
4-
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
4+
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
5+
target_include_directories(${TARGET} PRIVATE ../../common)
56
target_compile_features(${TARGET} PRIVATE cxx_std_11)
67
if(TARGET BUILD_INFO)
78
add_dependencies(${TARGET} BUILD_INFO)

examples/benchmark/benchmark-matmult.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#include "common.h"
12
#include "ggml.h"
2-
#include "build-info.h"
33

44
#include <locale.h>
55
#include <assert.h>
@@ -99,7 +99,7 @@ int main(int argc, char ** argv) {
9999
exit(1);
100100
}
101101

102-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
102+
print_build_info();
103103
printf("Starting Test\n");
104104

105105
// create the ggml context

examples/embd-input/embd-input-lib.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "common.h"
12
#include "embd-input.h"
23

34
#include <cassert>
@@ -22,7 +23,7 @@ struct MyModel* create_mymodel(int argc, char ** argv) {
2223
return nullptr;
2324
}
2425

25-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
26+
print_build_info();
2627

2728
if (params.seed == LLAMA_DEFAULT_SEED) {
2829
params.seed = uint32_t(time(NULL));

examples/embd-input/embd-input.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "common.h"
55
#include "llama.h"
6-
#include "build-info.h"
76

87
extern "C" {
98

examples/embedding/embedding.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22
#include "llama.h"
3-
#include "build-info.h"
43

54
#include <ctime>
65

@@ -17,7 +16,7 @@ int main(int argc, char ** argv) {
1716

1817
params.embedding = true;
1918

20-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
19+
print_build_info();
2120

2221
if (params.seed == LLAMA_DEFAULT_SEED) {
2322
params.seed = time(NULL);

examples/main/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ int main(int argc, char ** argv) {
149149
}
150150

151151
LOG_TEE("%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
152+
LOG_TEE("%s: built with %s for %s\n", __func__, BUILD_COMPILER, BUILD_TARGET);
152153

153154
if (params.seed == LLAMA_DEFAULT_SEED) {
154155
params.seed = time(NULL);

0 commit comments

Comments
 (0)