Skip to content

Commit 82b5578

Browse files
committed
---
yaml --- r: 274167 b: refs/heads/stable c: f78ce41 h: refs/heads/master i: 274165: fb27a9d 274163: 44a2131 274159: 9ed1d47
1 parent 89065ad commit 82b5578

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+989
-662
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 93d03edcb83d025ef40bd169ebf99214548d987f
32+
refs/heads/stable: f78ce412ef7b5137f91976dd93fb18865118ebae
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/Makefile.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,19 @@ endif
220220
# The test suite
221221
ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
222222
$(findstring test,$(MAKECMDGOALS)) \
223+
$(findstring perf,$(MAKECMDGOALS)) \
223224
$(findstring tidy,$(MAKECMDGOALS))),)
224225
CFG_INFO := $(info cfg: including test rules)
225226
include $(CFG_SRC_DIR)mk/tests.mk
226227
include $(CFG_SRC_DIR)mk/grammar.mk
227228
endif
228229

230+
# Performance and benchmarking
231+
ifneq ($(findstring perf,$(MAKECMDGOALS)),)
232+
CFG_INFO := $(info cfg: including perf rules)
233+
include $(CFG_SRC_DIR)mk/perf.mk
234+
endif
235+
229236
# Copy all the distributables to another directory for binary install
230237
ifneq ($(strip $(findstring prepare,$(MAKECMDGOALS)) \
231238
$(findstring dist,$(MAKECMDGOALS)) \

branches/stable/configure

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,22 +1361,16 @@ for h in $CFG_HOST
13611361
do
13621362
for t in $CFG_TARGET
13631363
do
1364-
# host bin dir stage0
1365-
make_dir $h/stage0/bin
1366-
13671364
# host lib dir stage0
13681365
make_dir $h/stage0/lib
13691366

1370-
# host test dir stage0
1371-
make_dir $h/stage0/test
1372-
13731367
# target bin dir stage0
13741368
make_dir $h/stage0/lib/rustlib/$t/bin
13751369

13761370
# target lib dir stage0
13771371
make_dir $h/stage0/lib/rustlib/$t/lib
13781372

1379-
for i in 1 2 3
1373+
for i in 0 1 2 3
13801374
do
13811375
# host bin dir
13821376
make_dir $h/stage$i/bin

branches/stable/mk/main.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,14 @@ STAGE$(1)_T_$(2)_H_$(3) := \
522522
$$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
523523
$$(RUSTC_FLAGS_$(2))
524524

525+
PERF_STAGE$(1)_T_$(2)_H_$(3) := \
526+
$$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
527+
$$(CFG_PERF_TOOL) \
528+
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
529+
--cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
530+
$$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
531+
$$(RUSTC_FLAGS_$(2))
532+
525533
endef
526534

527535
$(foreach build,$(CFG_HOST), \

branches/stable/mk/perf.mk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
# file at the top-level directory of this distribution and at
3+
# http://rust-lang.org/COPYRIGHT.
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
12+
ifdef CFG_PERF_TOOL
13+
rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
14+
@$(call E, perf compile: $@)
15+
$(PERF_STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
16+
-o $@ $(COMPILER_CRATE) >rustc-perf.err 2>&1
17+
$(Q)rm -f $(LIBRUSTC_GLOB)
18+
else
19+
rustc-perf$(X): $(CFG_BUILD)/stage2/bin/rustc$(X_$(CFG_BUILD))
20+
$(Q)touch $@
21+
endif
22+
23+
perf: check-stage2-perf rustc-perf$(X_$(CFG_BUILD))
24+
$(Q)find $(CFG_BUILD)/test/perf -name \*.err | xargs cat
25+
$(Q)cat rustc-perf.err

branches/stable/mk/platform.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ define DEF_GOOD_VALGRIND
7777
endef
7878
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_GOOD_VALGRIND,$(t))))
7979

80+
ifneq ($(findstring linux,$(CFG_OSTYPE)),)
81+
ifdef CFG_PERF
82+
ifneq ($(CFG_PERF_WITH_LOGFD),)
83+
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3 --log-fd 2
84+
else
85+
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3
86+
endif
87+
else
88+
ifdef CFG_VALGRIND
89+
CFG_PERF_TOOL := \
90+
$(CFG_VALGRIND) --tool=cachegrind --cache-sim=yes --branch-sim=yes
91+
else
92+
CFG_PERF_TOOL := /usr/bin/time --verbose
93+
endif
94+
endif
95+
endif
96+
8097
AR := ar
8198

8299
define SET_FROM_CFG

branches/stable/mk/tests.mk

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ ifdef CFG_VALGRIND
5050
CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
5151
endif
5252

53+
# Arguments to the perf tests
54+
ifdef CFG_PERF_TOOL
55+
CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
56+
endif
57+
5358
CTEST_TESTARGS := $(TESTARGS)
5459

5560
# --bench is only relevant for crate tests, not for the compile tests
@@ -65,6 +70,12 @@ endif
6570
# This prevents tests from failing with some locales (fixes #17423).
6671
export LC_ALL=C
6772

73+
# If we're running perf then set this environment variable
74+
# to put the benchmarks into 'hard mode'
75+
ifeq ($(MAKECMDGOALS),perf)
76+
export RUST_BENCH=1
77+
endif
78+
6879
TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
6980
TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
7081

@@ -475,6 +486,10 @@ CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
475486
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
476487
RUSTDOCCK_RS := $(wildcard $(S)src/test/rustdoc/*.rs)
477488

489+
# perf tests are the same as bench tests only they run under
490+
# a performance monitor.
491+
PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
492+
478493
RPASS_TESTS := $(RPASS_RS)
479494
RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RS)
480495
RPASS_FULL_TESTS := $(RPASS_FULL_RS)
@@ -484,6 +499,7 @@ RFAIL_TESTS := $(RFAIL_RS)
484499
CFAIL_TESTS := $(CFAIL_RS)
485500
PFAIL_TESTS := $(PFAIL_RS)
486501
BENCH_TESTS := $(BENCH_RS)
502+
PERF_TESTS := $(PERF_RS)
487503
PRETTY_TESTS := $(PRETTY_RS)
488504
DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
489505
DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
@@ -535,6 +551,11 @@ CTEST_BUILD_BASE_bench = bench
535551
CTEST_MODE_bench = run-pass
536552
CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
537553

554+
CTEST_SRC_BASE_perf = bench
555+
CTEST_BUILD_BASE_perf = perf
556+
CTEST_MODE_perf = run-pass
557+
CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
558+
538559
CTEST_SRC_BASE_debuginfo-gdb = debuginfo
539560
CTEST_BUILD_BASE_debuginfo-gdb = debuginfo-gdb
540561
CTEST_MODE_debuginfo-gdb = debuginfo-gdb
@@ -604,7 +625,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
604625
$$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
605626
$$(SREQ$(1)_T_$(2)_H_$(3))
606627

607-
# Rules for the cfail/rfail/rpass/bench test runner
628+
# Rules for the cfail/rfail/rpass/bench/perf test runner
608629

609630
# The tests select when to use debug configuration on their own;
610631
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
@@ -668,6 +689,7 @@ CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
668689
CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
669690
CTEST_DEPS_pfail_$(1)-T-$(2)-H-$(3) = $$(PFAIL_TESTS)
670691
CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
692+
CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
671693
CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS)
672694
CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
673695
$(S)src/etc/lldb_batchmode.py \
@@ -739,7 +761,7 @@ endif
739761
endef
740762

741763
CTEST_NAMES = rpass rpass-valgrind rpass-full rfail-full cfail-full rfail cfail pfail \
742-
bench debuginfo-gdb debuginfo-lldb codegen rustdocck
764+
bench perf debuginfo-gdb debuginfo-lldb codegen rustdocck
743765

744766
$(foreach host,$(CFG_HOST), \
745767
$(eval $(foreach target,$(CFG_TARGET), \
@@ -912,6 +934,7 @@ TEST_GROUPS = \
912934
cfail \
913935
pfail \
914936
bench \
937+
perf \
915938
rmake \
916939
rustdocck \
917940
debuginfo-gdb \

branches/stable/src/etc/cmathconsts.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
//
12+
// This is a helper C program for generating required math constants
13+
//
14+
// Should only be required when porting to a different target architecture
15+
// (or c compiler/libmath)
16+
//
17+
// Call with <rust machine type of c_float> <rust machine type of c_double>
18+
// and ensure that libcore/cmath.rs complies to the output
19+
//
20+
// Requires a printf that supports "%a" specifiers
21+
//
22+
23+
#include <float.h>
24+
#include <math.h>
25+
#include <stdio.h>
26+
27+
// must match std::ctypes
28+
29+
#define C_FLT(x) (float)x
30+
#define C_DBL(x) (double)x
31+
32+
int main(int argc, char** argv) {
33+
if (argc != 3) {
34+
fprintf(stderr, "%s <ctypes::c_float> <ctypes::c_double>\n", argv[0]);
35+
return 1;
36+
}
37+
char* c_flt = argv[1];
38+
char* c_dbl = argv[2];
39+
40+
printf("mod c_float_math_consts {\n");
41+
printf(" const pi: c_float = %a_%s;\n", C_FLT(M_PI), c_flt);
42+
printf(" const div_1_pi: c_float = %a_%s;\n", C_FLT(M_1_PI), c_flt);
43+
printf(" const div_2_pi: c_float = %a_%s;\n", C_FLT(M_2_PI), c_flt);
44+
printf(" const div_pi_2: c_float = %a_%s;\n", C_FLT(M_PI_2), c_flt);
45+
printf(" const div_pi_4: c_float = %a_%s;\n", C_FLT(M_PI_4), c_flt);
46+
printf(" const div_2_sqrtpi: c_float = %a_%s;\n",
47+
C_FLT(M_2_SQRTPI), c_flt);
48+
printf(" const e: c_float = %a_%s;\n", C_FLT(M_E), c_flt);
49+
printf(" const log2_e: c_float = %a_%s;\n", C_FLT(M_LOG2E), c_flt);
50+
printf(" const log10_e: c_float = %a_%s;\n", C_FLT(M_LOG10E), c_flt);
51+
printf(" const ln_2: c_float = %a_%s;\n", C_FLT(M_LN2), c_flt);
52+
printf(" const ln_10: c_float = %a_%s;\n", C_FLT(M_LN10), c_flt);
53+
printf(" const sqrt2: c_float = %a_%s;\n", C_FLT(M_SQRT2), c_flt);
54+
printf(" const div_1_sqrt2: c_float = %a_%s;\n",
55+
C_FLT(M_SQRT1_2), c_flt);
56+
printf("}\n\n");
57+
58+
printf("mod c_double_math_consts {\n");
59+
printf(" const pi: c_double = %a_%s;\n", C_DBL(M_PI), c_dbl);
60+
printf(" const div_1_pi: c_double = %a_%s;\n", C_DBL(M_1_PI), c_dbl);
61+
printf(" const div_2_pi: c_double = %a_%s;\n", C_DBL(M_2_PI), c_dbl);
62+
printf(" const div_pi_2: c_double = %a_%s;\n", C_DBL(M_PI_2), c_dbl);
63+
printf(" const div_pi_4: c_double = %a_%s;\n", C_DBL(M_PI_4), c_dbl);
64+
printf(" const div_2_sqrtpi: c_double = %a_%s;\n",
65+
C_DBL(M_2_SQRTPI), c_dbl);
66+
printf(" const e: c_double = %a_%s;\n", C_DBL(M_E), c_dbl);
67+
printf(" const log2_e: c_double = %a_%s;\n", C_DBL(M_LOG2E), c_dbl);
68+
printf(" const log10_e: c_double = %a_%s;\n", C_DBL(M_LOG10E), c_dbl);
69+
printf(" const ln_2: c_double = %a_%s;\n", C_DBL(M_LN2), c_dbl);
70+
printf(" const ln_10: c_double = %a_%s;\n", C_DBL(M_LN10), c_dbl);
71+
printf(" const sqrt2: c_double = %a_%s;\n", C_DBL(M_SQRT2), c_dbl);
72+
printf(" const div_1_sqrt2: c_double = %a_%s;\n",
73+
C_DBL(M_SQRT1_2), c_dbl);
74+
printf("}\n\n");
75+
76+
printf("mod c_float_targ_consts {\n");
77+
printf(" const radix: uint = %uu;\n", FLT_RADIX);
78+
printf(" const mantissa_digits: uint = %uu;\n", FLT_MANT_DIG);
79+
printf(" const digits: uint = %uu;\n", FLT_DIG);
80+
printf(" const min_exp: int = %i;\n", FLT_MIN_EXP);
81+
printf(" const max_exp: int = %i;\n", FLT_MAX_EXP);
82+
printf(" const min_10_exp: int = %i;\n", FLT_MIN_10_EXP);
83+
printf(" const max_10_exp: int = %i;\n", FLT_MAX_10_EXP);
84+
printf(" const min_value: c_float = %a_%s;\n", C_FLT(FLT_MIN), c_flt);
85+
printf(" const max_value: c_float = %a_%s;\n", C_FLT(FLT_MAX), c_flt);
86+
printf(" const epsilon: c_float = %a_%s;\n", C_FLT(FLT_EPSILON), c_flt);
87+
printf("}\n\n");
88+
89+
printf("mod c_double_targ_consts {\n");
90+
printf(" const radix: uint = %uu;\n", FLT_RADIX);
91+
printf(" const mantissa_digits: uint = %uu;\n", DBL_MANT_DIG);
92+
printf(" const digits: uint = %uu;\n", DBL_DIG);
93+
printf(" const min_exp: int = %i;\n", DBL_MIN_EXP);
94+
printf(" const max_exp: int = %i;\n", DBL_MAX_EXP);
95+
printf(" const min_10_exp: int = %i;\n", DBL_MIN_10_EXP);
96+
printf(" const max_10_exp: int = %i;\n", DBL_MAX_10_EXP);
97+
printf(" const min_value: c_double = %a_%s;\n", C_DBL(DBL_MIN), c_dbl);
98+
printf(" const max_value: c_double = %a_%s;\n", C_DBL(DBL_MAX), c_dbl);
99+
printf(" const epsilon: c_double = %a_%s;\n", C_DBL(DBL_EPSILON), c_dbl);
100+
printf("}\n");
101+
102+
return 0;
103+
}

0 commit comments

Comments
 (0)