-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
70 lines (55 loc) · 2.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
###################################################################
# Copyright (c) 2019
# Author(s): Marcus D. R. Klarqvist, Wojciech Muła, and Daniel Lemire
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
###################################################################
OPTFLAGS := -O3 -march=native
#OPTFLAGS := -O3 -march=cannonlake
WARNFLAGS := # -Wall -Wextra -pedantic
CFLAGS = -std=c99 $(OPTFLAGS) $(DEBUG_FLAGS) $(WARNFLAGS)
CPPFLAGS = -std=c++11 $(OPTFLAGS) $(DEBUG_FLAGS) $(WARNFLAGS)
CPP_SOURCE = benchmark.cpp benchmark/linux/instrumented_benchmark.cpp
C_SOURCE = pospopcnt.c example.c
OBJECTS = $(CPP_SOURCE:.cpp=.o) $(C_SOURCE:.c=.o)
# Default target
all: bench
# Generic rules
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.cpp
$(CXX) $(CPPFLAGS) -c -o $@ $<
benchmark/linux/instrumented_benchmark.o : benchmark/linux/instrumented_benchmark.cpp
$(CXX) $(CPPFLAGS) -I. -Ibenchmark/linux -c -o $@ $<
benchmark/linux/instrumented_benchmark_align64.o : benchmark/linux/instrumented_benchmark.cpp
$(CXX) $(CPPFLAGS) -DALIGN -I. -Ibenchmark/linux -c -o $@ $<
bench: pospopcnt.o benchmark.o
$(CXX) $(CPPFLAGS) pospopcnt.o benchmark.o -o bench
itest: instrumented_benchmark
$(CXX) --version
./instrumented_benchmark
DEPS=benchmark/linux/instrumented_benchmark.cpp benchmark/linux/linux-perf-events.h pospopcnt.h pospopcnt.c pospopcnt.o benchmark/linux/popcnt.h
instrumented_benchmark: $(DEPS) benchmark/linux/instrumented_benchmark.o
$(CXX) $(CPPFLAGS) pospopcnt.o benchmark/linux/instrumented_benchmark.o -I. -Ibenchmark/linux -o $@
instrumented_benchmark_align64: $(DEPS) benchmark/linux/instrumented_benchmark_align64.o
$(CXX) $(CPPFLAGS) pospopcnt.o benchmark/linux/instrumented_benchmark_align64.o -I. -Ibenchmark/linux -o $@
example: pospopcnt.o example.o
$(CC) $(CFLAGS) pospopcnt.o example.o -o example
test: bench
$(CXX) --version
./bench
clean:
rm -f $(OBJECTS)
rm -f bench example instrumented_benchmark
.PHONY: all clean test itest