Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a84918

Browse files
authored
Merge pull request #2192 from anutosh491/GSoC_PR_8
Added the `llvm_sym` backend for testing symbolic operations through the llvm backend
2 parents 45c05ee + 6dd1229 commit 9a84918

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,5 @@ jobs:
441441
shell: bash -e -l {0}
442442
run: |
443443
cd integration_tests
444-
./run_tests.py -b c_sym cpython_sym
445-
./run_tests.py -b c_sym cpython_sym -f
444+
./run_tests.py -b c_sym cpython_sym llvm_sym
445+
./run_tests.py -b c_sym cpython_sym llvm_sym -f

integration_tests/CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
105105
if (${fail})
106106
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
107107
endif()
108+
elseif(KIND STREQUAL "llvm_sym")
109+
add_custom_command(
110+
OUTPUT ${name}.o
111+
COMMAND ${LPYTHON} -c ${extra_args} ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.py -o ${name}.o
112+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.py
113+
VERBATIM)
114+
add_executable(${name} ${name}.o ${extra_files})
115+
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE C)
116+
if (APPLE)
117+
set(SYMENGINE_LIB "${Python_LIBRARY_DIRS}/libsymengine.dylib")
118+
else()
119+
set(SYMENGINE_LIB "${Python_LIBRARY_DIRS}/libsymengine.so")
120+
endif()
121+
target_link_libraries(${name} lpython_rtlib ${SYMENGINE_LIB})
122+
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
123+
if (labels)
124+
set_tests_properties(${name} PROPERTIES LABELS "${labels}")
125+
endif()
126+
if (${fail})
127+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
128+
endif()
108129
elseif(KIND STREQUAL "c")
109130
add_custom_command(
110131
OUTPUT ${name}.c
@@ -624,7 +645,7 @@ RUN(NAME symbolics_03 LABELS cpython_sym c_sym)
624645
RUN(NAME symbolics_04 LABELS cpython_sym c_sym)
625646
RUN(NAME symbolics_05 LABELS cpython_sym c_sym)
626647
RUN(NAME symbolics_06 LABELS cpython_sym c_sym)
627-
RUN(NAME symbolics_07 LABELS cpython_sym c_sym)
648+
RUN(NAME symbolics_07 LABELS cpython_sym c_sym llvm_sym NOFAST)
628649

629650
RUN(NAME sizeof_01 LABELS llvm c
630651
EXTRAFILES sizeof_01b.c)

integration_tests/run_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Initialization
88
DEFAULT_THREADS_TO_USE = 8 # default no of threads is 8
9-
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86', 'wasm_x64', 'c_py', 'c_sym', 'cpython_sym']
9+
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86', 'wasm_x64', 'c_py', 'c_sym', 'cpython_sym', 'llvm_sym']
1010
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
1111
LPYTHON_PATH = f"{BASE_DIR}/../src/bin"
1212

@@ -62,7 +62,7 @@ def main():
6262
DEFAULT_THREADS_TO_USE = args.no_of_threads or DEFAULT_THREADS_TO_USE
6363
fast_tests = "yes" if args.fast else "no"
6464
for backend in args.backends:
65-
python_libs_req = "yes" if backend in ["c_py", "c_sym"] else "no"
65+
python_libs_req = "yes" if backend in ["c_py", "c_sym", "llvm_sym"] else "no"
6666
test_backend(backend)
6767

6868

src/bin/lpython.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,14 @@ int link_executable(const std::vector<std::string> &infiles,
12181218
for (auto &s : infiles) {
12191219
cmd += s + " ";
12201220
}
1221+
if (compiler_options.enable_symengine) {
1222+
cmd += " -I${CONDA_PREFIX}/include";
1223+
}
12211224
cmd += + " -L"
12221225
+ base_path + " -Wl,-rpath," + base_path + " -l" + runtime_lib + " -lm";
1226+
if (compiler_options.enable_symengine) {
1227+
cmd += " -L$CONDA_PREFIX/lib -Wl,-rpath -Wl,$CONDA_PREFIX/lib -lsymengine";
1228+
}
12231229
int err = system(cmd.c_str());
12241230
if (err) {
12251231
std::cout << "The command '" + cmd + "' failed." << std::endl;

0 commit comments

Comments
 (0)