forked from syswonder/ruxos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from syswonder/dev
Dev
- Loading branch information
Showing
13 changed files
with
246 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
/.cache | ||
compile_commands.json | ||
|
||
# downloaded opensbi binary | ||
/fw_dynamic.bin | ||
|
||
*.asm | ||
disk.img | ||
actual.out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
std-benchmark/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
CMAKE = cmake | ||
|
||
ARCH ?= x86_64 | ||
C_COMPILER := $(shell which $(CC)) | ||
CXX_COMPILER := $(shell which $(CC)) | ||
AR := $(shell which $(AR)) | ||
RANLIB := $(shell which $(RANLIB)) | ||
CROSS_COMPILE_PATH := $(shell dirname $(C_COMPILER))/.. | ||
CXX_STD := c++20 | ||
CXX_STD ?= 20 | ||
|
||
app-objs := std_benchmark.o | ||
std_benchmark_dir := $(APP)/std-benchmark | ||
std_benchmark_build = $(std_benchmark_dir)/build | ||
|
||
bench ?= all | ||
benches_available := $(wildcard $(std_benchmark_dir)/cxx/*.bench.cpp) | ||
benches_available := $(patsubst $(std_benchmark_dir)/cxx/%.bench.cpp,%,$(benches_available)) | ||
|
||
main-obj := main.o | ||
app-objs := cpp.o | ||
$(std_benchmark_dir): | ||
@echo "Download std-benchmark source code" | ||
cd $(APP)/ && git clone --recursive https://github.com/hiraditya/std-benchmark | ||
patch -p1 -N -d $(std_benchmark_dir) --no-backup-if-mismatch -r - < $(APP)/std_benchmark.patch | ||
|
||
$(APP)/$(app-objs): build_cpp | ||
build_cpp: $(APP)/axbuild.mk $(APP)/main.cpp | ||
$(C_COMPILER) -o $(APP)/$(main-obj) -nostdlib -static -no-pie -c -std=$(CXX_STD) \ | ||
$(APP)/main.cpp -I$(CROSS_COMPILE_PATH)/*-linux-musl/include/c++/* | ||
$(LD) -o $(app-objs) $(APP)/$(main-obj) -nostdlib -static -no-pie -r -e main \ | ||
$(APP)/$(app-objs): build_std-benchmark | ||
build_std-benchmark: $(std_benchmark_dir) $(APP)/axbuild.mk | ||
cd $(std_benchmark_dir) && mkdir -p build && cd build && \ | ||
$(CMAKE) .. -DCMAKE_CXX_STANDARD=$(CXX_STD) -DCMAKE_C_COMPILER=$(C_COMPILER) -DCMAKE_CXX_COMPILER=$(CXX_COMPILER) -DCMAKE_AR=$(AR) -DCMAKE_RANLIB=$(RANLIB) \ | ||
-DENABLE_C_BENCHMARKS=OFF -DENABLE_C_VS_CXX_BENCHMARKS=OFF -DENABLE_COMPILER_VS_PROGRAMMER=OFF -DBENCHMARK_ENABLE_TESTING=OFF && \ | ||
$(MAKE) -j | ||
mkdir -p $(std_benchmark_build)/libgcc && cd $(std_benchmark_build)/libgcc && \ | ||
ln -s -f $(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc.a ./ && \ | ||
$(AR) x libgcc.a _clrsbsi2.o | ||
ifeq ($(bench), all) | ||
$(error "Running all benches automatically is not supported, please add 'bench=' arg. \ | ||
Available benches: $(benches_available)") | ||
endif | ||
ifneq ($(filter $(bench),$(benches_available)),) | ||
$(LD) -o $(app-objs) -nostdlib -static -no-pie -r -e main \ | ||
$(std_benchmark_build)/cxx/lib$(bench).bench.cpp.out.a \ | ||
$(std_benchmark_build)/benchmark/src/libbenchmark.a \ | ||
$(CROSS_COMPILE_PATH)/*-linux-musl/lib/libstdc++.a \ | ||
$(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc_eh.a | ||
$(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc_eh.a \ | ||
$(std_benchmark_build)/libgcc/_clrsbsi2.o | ||
else | ||
$(error "Available benches: $(benches_available)") | ||
endif | ||
|
||
clean_c:: | ||
rm -rf $(app-objs) | ||
rm -rf $(APP)/$(main-obj) | ||
rm -rf $(std_benchmark_build)/ | ||
|
||
.PHONY: build_std-benchmark clean_c | ||
|
||
|
||
.PHONY: build_cpp clean_c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ alloc | |
paging | ||
irq | ||
multitask | ||
fs | ||
random-hw |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- /cxx/CMakeLists.txt | ||
+++ /cxx/CMakeLists.txt | ||
@@ -3,7 +3,7 @@ foreach(test_path ${BENCHMARK_TESTS}) | ||
get_filename_component(test_file "${test_path}" NAME) | ||
set(target ${test_file}.out) | ||
#EXCLUDE_FROM_ALL | ||
- add_executable(${target} ${test_file}) | ||
+ add_library(${target} ${test_file}) | ||
# shlwapi for MSVC | ||
#target_link_libraries(${target} benchmark -pthread shlwapi) | ||
target_link_libraries(${target} benchmark -pthread) | ||
--- /cxx/mutators.bench.cpp | ||
+++ /cxx/mutators.bench.cpp | ||
@@ -26,8 +27,8 @@ void BM_write_seq(benchmark::State& state) { | ||
template<typename V> | ||
void BM_push_back(benchmark::State& state) { | ||
int N = state.range(0); | ||
- V v; | ||
while (state.KeepRunning()) { | ||
+ V v; | ||
for (int i = 0; i < N; ++i) | ||
v.push_back(i); | ||
} | ||
@@ -37,8 +38,8 @@ void BM_push_back(benchmark::State& state) { | ||
template<typename V> | ||
void BM_push_back_resize(benchmark::State& state) { | ||
int N = state.range(0); | ||
- V v(N); | ||
while (state.KeepRunning()) { | ||
+ V v(N); | ||
for (int i = 0; i < N; ++i) | ||
v.push_back(i); | ||
} | ||
@@ -48,9 +49,9 @@ void BM_push_back_resize(benchmark::State& state) { | ||
template<typename V> | ||
void BM_push_back_vector_reserve(benchmark::State& state) { | ||
int N = state.range(0); | ||
- V v; | ||
- v.reserve(N); | ||
while (state.KeepRunning()) { | ||
+ V v; | ||
+ v.reserve(N); | ||
for (int i = 0; i < N; ++i) | ||
v.push_back(i); | ||
} | ||
@@ -60,9 +61,9 @@ void BM_push_back_vector_reserve(benchmark::State& state) { | ||
template<typename V> | ||
void BM_insert_begin(benchmark::State& state) { | ||
int N = state.range(0); | ||
- V v(N, 1); | ||
- auto val = *v.begin(); | ||
while (state.KeepRunning()) { | ||
+ V v(N, 1); | ||
+ auto val = *v.begin(); | ||
v.insert(v.begin(), val); | ||
} | ||
state.SetComplexityN(N); | ||
@@ -94,14 +95,15 @@ void BM_assoc_insert_random(benchmark::State& state) { | ||
int N = state.range(0); | ||
using CVT = typename V::value_type; | ||
using VT = typename remove_const<CVT>::type; | ||
- std::vector<VT> temp(N*1000); | ||
+ // TODO: It will panic if *100 or *1000 | ||
+ std::vector<VT> temp(N*10); | ||
fill_random(temp); | ||
V v; | ||
auto it = temp.begin(); | ||
while (state.KeepRunning()) { | ||
v.insert(*it++); | ||
if (it == temp.end()) // FIXME: After temp.end insert will just return. | ||
- assert(0);//it = temp.begin(); | ||
+ it = temp.begin(); | ||
} | ||
state.SetComplexityN(N); | ||
} | ||
--- /include/test_configs.h | ||
+++ /include/test_configs.h | ||
@@ -1,6 +1,8 @@ | ||
#ifndef TEST_CONFIGS_H | ||
#define TEST_CONFIGS_H | ||
|
||
+void *__dso_handle = 0; | ||
+ | ||
#define KB << 10 | ||
#define MB << 20 | ||
#define GB << 30 | ||
@@ -12,9 +12,9 @@ | ||
#ifdef i7_4770 | ||
// To benchmark data residing completely in L1 cache. | ||
#ifndef ENABLE_TRAVIS_BUILD | ||
-#define L1 (32 KB) | ||
+#define L1 (16) | ||
// To benchmark data residing in L2 cache. | ||
-#define L2 (256 KB) | ||
+#define L2 (L1 << 7) | ||
#else | ||
// For the Travis CI to run the entire test. | ||
#define L1 (16 KB) | ||
--- /benchmark/CMakeLists.txt | ||
+++ /benchmark/CMakeLists.txt | ||
@@ -177,6 +177,8 @@ endif(BENCHMARK_USE_LIBCXX) | ||
cxx_feature_check(STD_REGEX) | ||
cxx_feature_check(GNU_POSIX_REGEX) | ||
cxx_feature_check(POSIX_REGEX) | ||
+add_compile_definitions(HAVE_STD_REGEX) | ||
+set(HAVE_STD_REGEX 1) | ||
if(NOT HAVE_STD_REGEX AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX) | ||
message(FATAL_ERROR "Failed to determine the source files for the regular expression backend") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.