rust 'rs' target

rust v1.0.0r
Avril 3 years ago
parent 14e3725fa9
commit 79ba15ecd2
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -3,8 +3,10 @@ INCLUDE=include
PROJECT=fcmp
OPT_FLAGS_RUST?= -C target-cpu=native
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4
FEAT_RUST?= threads
FEAT_CFLAGS?= -D_RUN_THREADED=0
FEAT_LDFLAGS?= -lpthread
@ -38,6 +40,9 @@ debug: | dirs $(PROJECT)-debug
.PHONY: pgo
pgo: | dirs $(PROJECT)-pgo
.PHONY: rs
rs: | $(PROJECT)-rs
dirs:
@mkdir -p {obj,prof}/src
@ -58,6 +63,10 @@ $(PROJECT)-debug: LDFLAGS := $(DEBUG_LDFLAGS) $(LDFLAGS)
$(PROJECT)-debug: $(OBJ)
$(CC) $^ $(CFLAGS) -o $@ $(LDFLAGS)
$(PROJECT)-rs:
cd fcmprs && OPT_FLAGS="$(OPT_FLAGS_RUST)" CARGO_FEATURES="$(FEAT_RUST)" $(MAKE)
cp -f ./fcmprs/target/release/fcmprs $@
pgo-generate: CFLAGS := $(RELEASE_CFLAGS) $(CFLAGS)
pgo-generate: LDFLAGS := $(RELEASE_LDFLAGS) $(LDFLAGS)
pgo-generate: $(PGO_OBJ)
@ -106,5 +115,6 @@ $(PROJECT)-pgo: pgo-profile
strip $@
clean:
cd fcmprs && make clean
rm -rf {obj,prof}
rm -f $(PROJECT)-{release,debug,pgo}
rm -f $(PROJECT)-{release,debug,pgo,rs}

@ -11,6 +11,12 @@ default = ["threads"]
threads = ["rayon"]
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
[dependencies]
cfg-if = "1.0.0"
memmap = "0.7.0"

@ -0,0 +1,76 @@
PROJECT = fcmprs
CARGO_FEATURES?= threads
OPT_FLAGS?= -C target-cpu=native
RUSTFLAGS?=
PROF_DIR=/tmp/fcmprs/prof
PROF_ITERATIONS?=100
PROF_LOCATION?=/tmp/fcmprs-profiters
PROF_LARGE_BOUND= $$(( 1024 * 1024 * 10 ))
PROF_SMALL_BOUND= $$(( 1024 * 10 ))
.PHONY: release
release: target/release/$(PROJECT)
.PHONY: debug
debug: target/debug/$(PROJECT)
.PHONY: pgo
pgo: target/release/$(PROJECT)-pgo
# Currently broken.
target/release/$(PROJECT): RUSTFLAGS+= $(OPT_FLAGS)
target/release/$(PROJECT):
RUSTFLAGS="$(RUSTFLAGS)" cargo build --release --no-default-features $(addprefix --features ,$(CARGO_FEATURES))
strip $@
target/debug/$(PROJECT):
RUSTFLAGS="$(RUSTFLAGS)" cargo build --no-default-features $(addprefix --features ,$(CARGO_FEATURES))
pgo-generate: RUSTFLAGS+= -Cprofile-generate=$(PROF_DIR)
pgo-generate: target/release/$(PROJECT)
pgo-profile: pgo-generate
for i in {1..$(PROF_ITERATIONS)}; do \
rm -rf $(PROF_LOCATION); \
mkdir -p $(PROF_LOCATION)/{large,small}; \
printf "Iteration $$i of $(PROF_ITERATIONS)\r"; \
../profile/gen $(PROF_LARGE_BOUND) "$(PROF_LOCATION)/large" >> /dev/null; \
../profile/gen $(PROF_SMALL_BOUND) "$(PROF_LOCATION)/small" >> /dev/null; \
./target/release/fcmprs $(PROF_LOCATION)/large/matching/* & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/large/unmatching/* & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/small/matching/* & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/small/unmatching/* & > $(PROF_LOCATION)/stdout; \
\
./target/release/fcmprs $(PROF_LOCATION)/small/matching/{1,2} & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/large/matching/{1,2} & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/small/unmatching/{1,2} & > $(PROF_LOCATION)/stdout; \
./target/release/fcmprs $(PROF_LOCATION)/large/unmatching/{1,2} & > $(PROF_LOCATION)/stdout; \
wait; \
rm -rf $(PROF_LOCATION)/{large,small}; \
done
@echo ""
rm -rf $(PROF_LOCATION)
llvm-profdata merge -o $(PROF_DIR)/merged.profdata $(PROF_DIR)
pgo-use: RUSTFLAGS+= -Cprofile-use=$(PROF_DIR)/merged.profdata -Cllvm-args=-pgo-warn-missing-function
pgo-use: target/release/$(PROJECT)
pgo-reset:
rm -rf $(PROF_DIR)
mkdir -p $(PROF_DIR)
target/release/$(PROJECT)-pgo: | pgo-reset pgo-profile
#rm -rf target
CARGO_INCREMENTAL=0 $(MAKE) -B pgo-use
mv -f target/release/$(PROJECT) $@
clean:
rm -rf target
rm -rf $(PROF_LOCATION) $(PROF_DIR)

@ -31,7 +31,7 @@ fn main() {
}
};
std::process::exit(dbg!{
std::process::exit({
if let Some(map1) = map::map(&map1).discard_msg(format!("Failed to map file {}", map1)) {
let slice = map1.as_slice();
let mut ok = true;

Loading…
Cancel
Save