Loading python/tests/CMakeLists.txt +7 −0 Original line number Diff line number Diff line Loading @@ -81,3 +81,10 @@ add_test (NAME qcor_python_compute_action set_tests_properties(qcor_python_compute_action PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_INSTALL_PREFIX}:$ENV{PYTHONPATH}") add_test (NAME qcor_python_bug_89 COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_jit_find_kernel_function_bug_89.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) set_tests_properties(qcor_python_bug_89 PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_INSTALL_PREFIX}:$ENV{PYTHONPATH}") No newline at end of file python/tests/test_jit_find_kernel_function_bug_89.py 0 → 100644 +26 −0 Original line number Diff line number Diff line import faulthandler faulthandler.enable() import unittest from qcor import * class TestJITBug89(unittest.TestCase): def test_89(self): set_qpu('qpp', {'shots': 100}) @qjit def t(q: qreg): H(q) Measure(q) q = qalloc(2) t(q) q.print() counts = q.counts() print(counts) self.assertEqual(len(counts), 4) if __name__ == '__main__': unittest.main() No newline at end of file runtime/jit/qcor_jit.in.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -563,7 +563,11 @@ void QJIT::jit_compile(const std::string &code, hetmap_mangled_name = "", parent_hetmap_mangled_name = ""; for (Function &f : *module) { auto name = f.getName().str(); if (demangle(name.c_str()).find(kernel_name) != std::string::npos) { auto demangled = demangle(name.c_str()); // Find first '(' lparen auto first = demangled.find_first_of("("); // We want str[0:first] == kernel_name if (demangled.substr(0, first) == kernel_name) { // First one we see is the correct kernel call mangled_name = name; break; Loading Loading
python/tests/CMakeLists.txt +7 −0 Original line number Diff line number Diff line Loading @@ -81,3 +81,10 @@ add_test (NAME qcor_python_compute_action set_tests_properties(qcor_python_compute_action PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_INSTALL_PREFIX}:$ENV{PYTHONPATH}") add_test (NAME qcor_python_bug_89 COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_jit_find_kernel_function_bug_89.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) set_tests_properties(qcor_python_bug_89 PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_INSTALL_PREFIX}:$ENV{PYTHONPATH}") No newline at end of file
python/tests/test_jit_find_kernel_function_bug_89.py 0 → 100644 +26 −0 Original line number Diff line number Diff line import faulthandler faulthandler.enable() import unittest from qcor import * class TestJITBug89(unittest.TestCase): def test_89(self): set_qpu('qpp', {'shots': 100}) @qjit def t(q: qreg): H(q) Measure(q) q = qalloc(2) t(q) q.print() counts = q.counts() print(counts) self.assertEqual(len(counts), 4) if __name__ == '__main__': unittest.main() No newline at end of file
runtime/jit/qcor_jit.in.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -563,7 +563,11 @@ void QJIT::jit_compile(const std::string &code, hetmap_mangled_name = "", parent_hetmap_mangled_name = ""; for (Function &f : *module) { auto name = f.getName().str(); if (demangle(name.c_str()).find(kernel_name) != std::string::npos) { auto demangled = demangle(name.c_str()); // Find first '(' lparen auto first = demangled.find_first_of("("); // We want str[0:first] == kernel_name if (demangled.substr(0, first) == kernel_name) { // First one we see is the correct kernel call mangled_name = name; break; Loading