Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,8 @@ StatementMacros:
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
---
Language: Json
DisableFormat: true
...
# vim: set ft=yaml ts=2 sw=2 :
10 changes: 9 additions & 1 deletion .github/workflows/build-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@ concurrency:

jobs:
linux:
name: ${{matrix.runner}}-${{matrix.compiler}}-${{matrix.version}}-llvm${{matrix.llvm}}
name: ${{matrix.runner}}-${{matrix.compiler}}-${{matrix.version}}-${{ matrix.shared && 'shared' || 'static' }}-llvm${{matrix.llvm}}
strategy:
matrix:
include:
- runner: jammy
compiler: gcc
version: 12
llvm: 14
shared: true
- runner: jammy
compiler: gcc
version: 12
llvm: 14
shared: false
- runner: jammy
compiler: clang
version: 15
llvm: 15
shared: true
runs-on: >-
${{ matrix.runner == 'focal' && 'ubuntu-20.04'
|| matrix.runner == 'jammy' && 'ubuntu-22.04'
Expand Down Expand Up @@ -67,6 +74,7 @@ jobs:
-DQIREE_BUILD_TESTS:BOOL=ON \
-DQIREE_DEBUG:BOOL=ON \
-DQIREE_USE_XACC:BOOL=OFF \
-DQIREE_SHARED_LIBS:BOOL=${{ matrix.shared }} \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install" \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ repos:
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-yaml
# .clang-format contains multiple documents for different languages
args: ['--allow-multiple-documents']
- id: end-of-file-fixer
exclude: '\.(diff|patch)$'
- id: trailing-whitespace
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ set(QIREE_RUNTIME_OUTPUT_DIRECTORY
enable_language(C) # Needed for LLVM
find_package(LLVM REQUIRED)
if((LLVM_VERSION VERSION_LESS 14)
OR (LLVM_VERSION VERSION_GREATER_EQUAL 21))
message(WARNING "QIR-EE is only tested with LLVM 14-20: found version ${LLVM_VERSION}")
OR (LLVM_VERSION VERSION_GREATER_EQUAL 22))
message(WARNING "QIR-EE is only tested with LLVM 14-21: found version ${LLVM_VERSION}")
endif()

if(QIREE_USE_QSIM)
Expand Down
4 changes: 0 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
"binaryDir": "${sourceDir}/build-${presetName}",
"generator": "Ninja",
"cacheVariables": {
"BUILD_SHARED_LIBS": {
"type": "BOOL",
"value": "ON"
},
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Debug"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ doc` (user) or `make doxygen` (developer).

There are two dependencies for QIR-EE to work properly. Please make sure to
download and install the most current versions of:
1. [LLVM](https://releases.llvm.org/) (we have tested versions 14 through 18)
1. [LLVM](https://releases.llvm.org/) (we have tested versions 14 through 21)
2. [XACC](https://github.com/ORNL-QCI/xacc) (repo that is actively
maintained -- not the eclipse one; currently required for execution in
this version of qir-ee; we recommend setting option `-DQIREE_MINIMAL_BUILD=ON`
Expand Down
16 changes: 12 additions & 4 deletions src/cqiree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ if(QIREE_USE_QSIM)
list(APPEND _CQIREE_LIBS QIREE::qirqsim)
endif()

qiree_add_library(cqiree MODULE
if(BUILD_SHARED_LIBS)
# When building with shared libs, this should be a shared library that can
# be dlopen()'d.
set(_LIB_TYPE MODULE)
else()
set(_LIB_TYPE)
endif()

qiree_add_library(cqiree ${_LIB_TYPE}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative to this is to use an object library that allows us to build a dlopen-compatible module and a linkable (shared or static) library... @miniskar thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you want me to attempt this

CQiree.cc
QireeManager.cc
)
Expand All @@ -28,10 +36,10 @@ target_link_libraries(cqiree
#----------------------------------------------------------------------------#

# C/C++ source headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cqiree"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cqiree"
COMPONENT development
FILES_MATCHING REGEX ".*\\.hh$"
FILES_MATCHING REGEX ".*\\.h$"
)

#-----------------------------------------------------------------------------#
7 changes: 3 additions & 4 deletions src/cqiree/CQiree.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
//---------------------------------------------------------------------------//
#pragma once

#include <cstdint>
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>
#include <stdint.h>

/* Opaque pointer to QireeManager */
typedef struct CQiree_s CQiree;

Expand Down
8 changes: 7 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ qiree_add_test(qiree ResultDistribution)
#---------------------------------------------------------------------------##

qiree_add_test(cqiree CQiree)
add_dependencies(cqiree_CQireeTest cqiree)
if(BUILD_SHARED_LIBS)
# Tester uses dlopen()
add_dependencies(cqiree_CQireeTest cqiree)
else()
# Statically link tester with cqiree
target_link_libraries(cqiree_CQireeTest cqiree)
endif()

#---------------------------------------------------------------------------##
# QIRXACC TESTS
Expand Down
21 changes: 15 additions & 6 deletions test/cqiree/CQiree.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
//---------------------------------------------------------------------------//
#include "cqiree/CQiree.h"

#include <algorithm>
#include <array>
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
#include <dlfcn.h>

#include "qiree_config.h"
#include "qiree_targets.h"
#include "qiree_test_config.h"

#include "qiree/Assert.hh"
#include "qiree_test.hh"
Expand Down Expand Up @@ -43,15 +46,21 @@ class CQireeTest : public ::qiree::test::Test
protected:
void SetUp() override
{
#if BUILD_SHARED_LIBS
lib_handle_ = dlopen(cqiree_library_path, RTLD_LAZY);
ASSERT_NE(lib_handle_, nullptr)
<< "Failed to load libcqiree: " << dlerror();

#define LOAD_FUNCPTR(FUNC) \
FUNC##_fn_ = reinterpret_cast<qiree_##FUNC##_t>( \
dlsym(lib_handle_, "qiree_" #FUNC)); \
ASSERT_NE(FUNC##_fn_, nullptr) \
<< "Failed to load " << #FUNC << ": " << dlerror();
#endif

#if BUILD_SHARED_LIBS
# define LOAD_FUNCPTR(FUNC) \
FUNC##_fn_ = reinterpret_cast<qiree_##FUNC##_t>( \
dlsym(lib_handle_, "qiree_" #FUNC)); \
ASSERT_NE(FUNC##_fn_, nullptr) \
<< "Failed to load " << #FUNC << ": " << dlerror();
#else
# define LOAD_FUNCPTR(FUNC) FUNC##_fn_ = qiree_##FUNC;
#endif
LOAD_FUNCPTR(create);
LOAD_FUNCPTR(load_module_from_memory);
LOAD_FUNCPTR(load_module_from_file);
Expand Down
2 changes: 2 additions & 0 deletions test/qiree_test_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef qiree_test_config_h
#define qiree_test_config_h

#cmakedefine01 BUILD_SHARED_LIBS

static char const qiree_source_dir[] = "@QIREE_SOURCE_DIR@";

#endif /* qiree_test_config_h */