Are there any JIT mode optimizations flags?
Hi, I'm trying to compare daScript performance with the performance of my programming language (Spawn) in the Fibonacci example. daScript's performance info states the following:
daScript Just-in-Time compilation is based on LLVM backend, and often outperforms C++, due to daScript providing more information to LLVM than AOT.
and provides the following table
daScript code I'm benchmarking is the following:
def fibI(n)
var last = 1
var cur = 0
for i in range(n)
let tmp = cur
cur += last
last = tmp
return cur
[export]
def main
print("{fibI(6511134)}")
I'm running it with just das fibI.das
Spawn code is the following:
fn main() {
print('${fib_i(6511134)}')
}
fn fib_i(n u64) -> u64 {
mut last := 1
mut cur := 0
for i in 0 .. n {
tmp := cur
cur += last
last = tmp
}
return cur
}
I'm building executable with ./spawnlang --cc clang --opt-fast --show-timings=false -o fib_sp ../fibI.sp
I'm comparing both daScript and Spawn using hyperfine hyperfine -N --warmup 5 "das fibI.das" ../../spawn/fib_sp
The results are the following
Benchmark 1: das fibI.das
Time (mean ± σ): 292.5 ms ± 11.0 ms [User: 276.2 ms, System: 13.6 ms]
Range (min … max): 275.4 ms … 319.6 ms 10 runs
Benchmark 2: ../../spawn/fib_sp
Time (mean ± σ): 4.5 ms ± 0.6 ms [User: 3.1 ms, System: 1.1 ms]
Range (min … max): 2.2 ms … 5.9 ms 574 runs
Summary
../../spawn/fib_sp ran
64.72 ± 8.79 times faster than das fibI.das
Am I doing something wrong? Should I add any optimization flags to daScript build command or something? I can't try AOT for now (see #1119), but seems JIT mode of daScript should perform sometimes better than AOT mode, and I have drastically difference in comparison with my compiled programming language that should have similar performance as AOT
I'm on Arch Linux, with lastest GCC and Clang and dev tools
I found options optimize=true in https://spiiin.github.io/blog/2115627465/ and added it on the top of my file, but seems this changed nothing in term of performance
das -jit fibI.das it runs interpreted otherwise
Hi, thanks for the response. Unfortunately, this doesn't work for me
╰─λ das -jit fibI.das
failed to add extra dependency just_in_time from /home/yuart/Projects/daScript/daslib/just_in_time.das
function 'main' not found
u'r missing dasLLVM submodule
Hmm, when running python modules.py --path ./build --on dasLLVM from the root of the daScript repo folder, I have the following output
🔴] × python modules.py --path ./build --on dasLLVM
/home/yuart/Projects/daScript/modules.py:238: SyntaxWarning: invalid escape sequence '\d'
description='''This is cmake/git configuration tool.
CMake Warning at modules/dasClangBind/CMakeLists.txt:6 (message):
can't find libclang at /home/yuart/Projects/daScript/../libclang
Call Stack (most recent call first):
CMakeLists.txt:273 (INCLUDE)
-- dasGlsl module included.
CMake Warning at modules/dasLLVM/CMakeLists.txt:4 (message):
can't find libclang at /home/yuart/Projects/daScript/../libclang
Call Stack (most recent call first):
CMakeLists.txt:273 (INCLUDE)
-- dasOpenAI module included.
-- dasOpenGL module included.
-- dasPEG module included.
-- dasStbImage module included.
REGISTER DAS MODULE libDasModuleStbImage
-- dasStbTrueType module included.
REGISTER DAS MODULE libDasModuleStbTrueType
-- dasStdDlg module included.
REGISTER DAS MODULE libDasModuleStdDlg
-- dasTELEGRAM module included.
-- FLEX `2.6.4` found
-- BISON `3.8.2` found
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- Configuring done (0.4s)
-- Generating done (0.1s)
-- Build files have been written to: /home/yuart/Projects/daScript
dasLLVM turned on successfully (see log above)!
Q - exit, U - update list, D - disable all modules, arrows/J/K - navigation, enter - toggle module state
- : dasAudio
- : dasBGFX
- : dasClangBind
+ : dasGlfw
: dasGlsl - option for this module is unknown
- : dasHV
- : dasImgui
-> - : dasLLVM
- : dasMinfft
: dasOpenAI - option for this module is unknown
: dasOpenGL - option for this module is unknown
: dasPEG - option for this module is unknown
: dasPUGIXML - option for this module is unknown
- : dasQuirrel
- : dasSFML
: dasSQLITE - option for this module is unknown
+ : dasStbImage
+ : dasStbTrueType
+ : dasStdDlg
: dasTelegram - option for this module is unknown
- : dasXbyak
What exactly is libclang?
installation of LLVM. 16.0.6 inside looks like this
02/29/2024 10:26 AM <DIR> bin
11/03/2023 10:56 PM <DIR> include
02/29/2024 10:26 AM <DIR> lib
02/29/2024 10:26 AM <DIR> libexec
02/29/2024 10:26 AM <DIR> share
Ok, trying
I downloaded llvm-18.1.6.src.tar.xz from https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.6, and just renamed it into libclang and placed to suitable place.
Its content
Now python modules.py --path ./build --on dasLLVM outputs the following
/home/yuart/Projects/daScript/modules.py:238: SyntaxWarning: invalid escape sequence '\d'
description='''This is cmake/git configuration tool.
-- dasClangBind module included.
LIBCLANG_INCLUDE at /home/yuart/Projects/daScript/../libclang/include
LIBCLANG_LIB at /home/yuart/Projects/daScript/../libclang/lib
REGISTER DAS MODULE libDasModuleClangBind
-- dasGlsl module included.
-- dasLlvm module included.
LIBCLANG_INCLUDE at /home/yuart/Projects/daScript/../libclang/include
LIBCLANG_LIB at /home/yuart/Projects/daScript/../libclang/lib
REGISTER DAS MODULE libDasModuleLlvm
-- dasOpenAI module included.
-- dasOpenGL module included.
-- dasPEG module included.
-- dasStbImage module included.
REGISTER DAS MODULE libDasModuleStbImage
-- dasStbTrueType module included.
REGISTER DAS MODULE libDasModuleStbTrueType
-- dasStdDlg module included.
REGISTER DAS MODULE libDasModuleStdDlg
-- dasTELEGRAM module included.
-- FLEX `2.6.4` found
-- BISON `3.8.2` found
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- File is not changed. Generation skipped.
-- Configuring done (0.4s)
CMake Error at modules/dasLLVM/CMakeLists.txt:133 (ADD_LIBRARY):
Cannot find source file:
/home/yuart/Projects/daScript/modules/dasLlvm/src/cb_dasLLVM.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
.ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
.f95 .f03 .hip .ispc
Call Stack (most recent call first):
CMakeLists.txt:273 (INCLUDE)
CMake Error at modules/dasLLVM/CMakeLists.txt:133 (ADD_LIBRARY):
No SOURCES given to target: libDasModuleLlvm
Call Stack (most recent call first):
CMakeLists.txt:273 (INCLUDE)
CMake Generate step failed. Build files cannot be regenerated correctly.
ERROR: there was an error executing 'cmake -DDAS_LLVM_DISABLED:BOOL=OFF /home/yuart/Projects/daScript'
Hmm, but the file is present
https://t.me/daScript since this is turning into chat