@@ -148,19 +148,21 @@ ifdef LLAMA_PERF
148
148
CXXFLAGS += -DGGML_PERF
149
149
endif
150
150
ifneq ($(filter aarch64% ,$(UNAME_M ) ) ,)
151
+ # Apple M1, M2, etc.
152
+ # Raspberry Pi 3, 4, Zero 2 (64-bit)
151
153
CFLAGS += -mcpu=native
152
154
CXXFLAGS += -mcpu=native
153
155
endif
154
156
ifneq ($(filter armv6% ,$(UNAME_M ) ) ,)
155
- # Raspberry Pi 1, 2, 3
157
+ # Raspberry Pi 1, Zero
156
158
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
157
159
endif
158
160
ifneq ($(filter armv7% ,$(UNAME_M ) ) ,)
159
- # Raspberry Pi 4
161
+ # Raspberry Pi 2
160
162
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
161
163
endif
162
164
ifneq ($(filter armv8% ,$(UNAME_M ) ) ,)
163
- # Raspberry Pi 4
165
+ # Raspberry Pi 3, 4, Zero 2 (32-bit)
164
166
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
165
167
endif
166
168
@@ -192,41 +194,56 @@ llama.o: llama.cpp ggml.h ggml-cuda.h llama.h llama-util.h
192
194
common.o : examples/common.cpp examples/common.h
193
195
$(CXX ) $(CXXFLAGS ) -c $< -o $@
194
196
197
+ libllama.so : llama.o ggml.o $(OBJS )
198
+ $(CXX ) $(CXXFLAGS ) -shared -fPIC -o $@ $^ $(LDFLAGS )
199
+
195
200
clean :
196
- rm -vf * .o main quantize quantize-stats perplexity embedding benchmark-matmult
201
+ rm -vf * .o main quantize quantize-stats perplexity embedding benchmark-matmult save-load-state build-info.h
197
202
198
- main : examples/main/main.cpp ggml.o llama.o common.o $(OBJS )
199
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
203
+ #
204
+ # Examples
205
+ #
206
+
207
+ main : examples/main/main.cpp build-info.h ggml.o llama.o common.o $(OBJS )
208
+ $(CXX ) $(CXXFLAGS ) $(filter-out % .h,$^ ) -o $@ $(LDFLAGS )
200
209
@echo
201
210
@echo ' ==== Run ./main -h for help. ===='
202
211
@echo
203
212
204
- quantize : examples/quantize/quantize.cpp ggml.o llama.o $(OBJS )
205
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
213
+ quantize : examples/quantize/quantize.cpp build-info.h ggml.o llama.o $(OBJS )
214
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
206
215
207
- quantize-stats : examples/quantize-stats/quantize-stats.cpp ggml.o llama.o $(OBJS )
208
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
216
+ quantize-stats : examples/quantize-stats/quantize-stats.cpp build-info.h ggml.o llama.o $(OBJS )
217
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
209
218
210
- perplexity : examples/perplexity/perplexity.cpp ggml.o llama.o common.o $(OBJS )
211
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
219
+ perplexity : examples/perplexity/perplexity.cpp build-info.h ggml.o llama.o common.o $(OBJS )
220
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
212
221
213
- embedding : examples/embedding/embedding.cpp ggml.o llama.o common.o $(OBJS )
214
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
222
+ embedding : examples/embedding/embedding.cpp build-info.h ggml.o llama.o common.o $(OBJS )
223
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
215
224
216
- vdot : pocs/vdot/vdot .cpp ggml.o $(OBJS )
217
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
225
+ save-load-state : examples/save-load-state/save-load-state .cpp build-info.h ggml.o llama.o common .o $(OBJS )
226
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
218
227
219
- libllama.so : llama.o ggml.o $(OBJS )
220
- $(CXX ) $(CXXFLAGS ) -shared -fPIC -o $@ $^ $(LDFLAGS )
228
+ build-info.h : $(wildcard .git/index) scripts/build-info.sh
229
+ @scripts/build-info.sh > $@ .tmp
230
+ @if ! cmp -s $@ .tmp $@ ; then \
231
+ mv $@ .tmp $@ ; \
232
+ else \
233
+ rm $@ .tmp; \
234
+ fi
221
235
222
236
#
223
237
# Tests
224
238
#
225
239
226
- benchmark-matmult : examples/benchmark/benchmark-matmult.cpp ggml.o $(OBJS )
227
- $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
240
+ benchmark-matmult : examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS )
241
+ $(CXX ) $(CXXFLAGS ) $( filter-out % .h, $^ ) -o $@ $(LDFLAGS )
228
242
./$@
229
243
244
+ vdot : pocs/vdot/vdot.cpp ggml.o $(OBJS )
245
+ $(CXX ) $(CXXFLAGS ) $^ -o $@ $(LDFLAGS )
246
+
230
247
.PHONY : tests
231
248
tests :
232
249
bash ./tests/run-tests.sh
0 commit comments