Skip to content

Commit 151b72e

Browse files
committed
updated COAT to get source line support when profiling AsmJit
1 parent 87aeb5c commit 151b72e

File tree

8 files changed

+47
-15
lines changed

8 files changed

+47
-15
lines changed

.gitmodules

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[submodule "external/asmjit"]
22
path = external/asmjit
3-
url = https://github.com/tetzank/asmjit
4-
branch = mywip
3+
url = https://github.com/asmjit/asmjit
4+
branch = master
55
[submodule "external/llvm"]
66
path = external/llvm
77
url = https://github.com/llvm/llvm-project
88
branch = release/7.x
99
[submodule "external/coat"]
1010
path = external/coat
1111
url = https://github.com/tetzank/coat.git
12+
[submodule "external/asmjit-utilities"]
13+
path = external/asmjit-utilities
14+
url = https://github.com/tetzank/asmjit-utilities

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ find_library(ASMJIT_LIBRARIES
3131
)
3232
include_directories(${ASMJIT_INCLUDE_DIR})
3333

34+
# find asmjit_perf
35+
find_path(ASMJIT_PERF_INCLUDE_DIR
36+
asmjit-utilities/perf/jitdump.h
37+
HINTS external/
38+
)
39+
find_library(ASMJIT_PERF_LIBRARIES
40+
asmjit_perf
41+
HINTS external/asmjit-utilities
42+
PATH_SUFFIXES perf/build
43+
)
44+
include_directories(${ASMJIT_PERF_INCLUDE_DIR})
45+
3446
# find llvm, quick&dirty
3547
find_path(LLVM_INCLUDE_DIR
3648
llvm/IR/IRBuilder.h
@@ -93,7 +105,8 @@ if(MEASURE_TIME)
93105
endif()
94106
option(PROFILING "enable perf profiling support" OFF)
95107
if(PROFILING)
96-
target_compile_definitions(sig18 PRIVATE "PROFILING")
108+
target_compile_definitions(sig18 PRIVATE "PROFILING" PRIVATE "PROFILING_SOURCE")
109+
target_link_libraries(sig18 ${ASMJIT_PERF_LIBRARIES})
97110
endif()
98111

99112
# debugging options

buildDependencies.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ git submodule update --init
77
pushd external/asmjit
88
mkdir -p build
99
cd build
10-
cmake -DCMAKE_BUILD_TYPE=Release -DASMJIT_BUILD_STATIC=TRUE ..
10+
cmake -DCMAKE_BUILD_TYPE=Release ..
11+
make $@
12+
popd
13+
14+
pushd external/asmjit-utilities
15+
mkdir -p perf/build
16+
cd perf/build
17+
ASMJIT_ROOT=../../../external/asmjit cmake -DCMAKE_BUILD_TYPE=Release ..
1118
make $@
1219
popd
1320

external/asmjit

Submodule asmjit updated 174 files

external/asmjit-utilities

Submodule asmjit-utilities added at 6a26750

include/Operator.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ struct CodegenContext {
6161

6262
CodegenContext(Fn &fn, size_t numberOfRelations, size_t numberOfProjections)
6363
: arguments(fn.getArguments("lower", "upper", "proj_addr"))
64-
, rowids(numberOfRelations, coat::Value<CC,uint64_t>(fn))
65-
, results(numberOfProjections, coat::Value<CC,uint64_t>(fn, 0UL))
6664
, amount(fn, 0UL, "amount")
67-
{}
65+
{
66+
// emplace_back() in a loop to avoid copies
67+
rowids.reserve(numberOfRelations);
68+
for(size_t i=0; i<numberOfRelations; ++i){
69+
rowids.emplace_back(fn);
70+
}
71+
results.reserve(numberOfProjections);
72+
for(size_t i=0; i<numberOfProjections; ++i){
73+
results.emplace_back(fn);
74+
}
75+
}
6876
};
6977

7078

src/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,21 @@ void codegenAsmjit(
280280
#ifdef MEASURE_TIME
281281
auto t_start = std::chrono::high_resolution_clock::now();
282282
#endif
283+
#ifdef PROFILING
284+
char buf[8]={};
285+
snprintf(buf, sizeof(buf), "q%lu", query);
286+
coat::Function<coat::runtimeasmjit,codegen_func_type> fn(*asmrt, buf);
287+
#else
283288
coat::Function<coat::runtimeasmjit,codegen_func_type> fn(*asmrt);
289+
#endif
284290
{
285291
CodegenContext ctx(fn, q.relationIds.size(), q.selections.size());
286292
scan->codegen(fn, ctx);
287293
proj->codegen_save(fn, ctx);
288294
coat::ret(fn, ctx.amount);
289295
}
290296
// finalize function
291-
#ifdef PROFILING
292-
char buf[8]={};
293-
snprintf(buf, sizeof(buf), "q%lu", query);
294-
codegen_func_type fnptr = fn.finalize(buf);
295-
#else
296297
codegen_func_type fnptr = fn.finalize();
297-
#endif
298298
#ifdef MEASURE_TIME
299299
auto t_compile = std::chrono::high_resolution_clock::now();
300300
#endif

0 commit comments

Comments
 (0)