Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove standalone and qobj #2187

Merged
merged 22 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
109 changes: 0 additions & 109 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,117 +8,8 @@ concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
standalone:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-13", "ubuntu-latest", "windows-2019"]
steps:
- uses: actions/checkout@v4
- name: Set up Python '3.10'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install deps
run: pip install "conan<2.0.0"
- name: Install openblas
run: |
set -e
sudo apt-get update
sudo apt-get install -y libopenblas-dev
shell: bash
if: runner.os == 'Linux'
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
if: runner.os == 'Windows'
- name: Compile Standalone Windows
run: |
set -e
mkdir out; cd out; cmake .. -DBUILD_TESTS=1
cmake --build . --config Release
shell: bash
if: runner.os == 'Windows'
- name: Compile Standalone
run: |
set -e
mkdir out; cd out; cmake .. -DBUILD_TESTS=1
make
shell: bash
if: runner.os != 'Windows'
- name: Run Unit Tests
run: |
cd out/bin
for test in test*
do echo $test
if ! ./$test
then
ERR=1
fi
done
if [ ! -z "$ERR" ]
then
exit 1
fi
shell: bash
- name: Run qobj
run: |
pip install -U qiskit
python tools/generate_qobj.py
cd out
Release/qasm_simulator ../qobj.json | python ../tools/verify_standalone_results.py
shell: bash
mpi_standalone:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v4
- name: Set up Python '3.10'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install deps
run: pip install "conan<2.0.0"
- name: Install openblas and mpi
run: |
set -e
sudo apt-get update
sudo apt-get install -y libopenblas-dev openmpi-bin libopenmpi-dev
shell: bash
- name: Compile Standalone
run: |
set -e
mkdir out; cd out; cmake .. -DBUILD_TESTS=1 -DAER_MPI=True
make
shell: bash
- name: Run Unit Tests with mpi
run: |
cd out/bin
for test in test*
do echo $test
if ! /usr/bin/mpirun.openmpi -host localhost:2 -np 2 ./$test
then
ERR=1
fi
done
if [ ! -z "$ERR" ]
then
exit 1
fi
shell: bash
- name: Run qobj
run: |
pip install -U qiskit
python tools/generate_qobj.py
cd out
/usr/bin/mpirun.openmpi -host localhost:2 -np 2 Release/qasm_simulator ../qobj.json | python ../tools/verify_standalone_results.py
env:
USE_MPI: 1
shell: bash
wheel:
runs-on: ${{ matrix.os }}
needs: ["standalone"]
strategy:
matrix:
os: ["macos-13", "ubuntu-latest", "windows-2019"]
Expand Down
151 changes: 1 addition & 150 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ include(dependency_utils)

# Get version information
get_version(${VERSION_NUM})
configure_file("${PROJECT_SOURCE_DIR}/contrib/standalone/version.hpp.in"
"${PROJECT_SOURCE_DIR}/contrib/standalone/version.hpp")

set(AER_SIMULATOR_CPP_SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS
Expand Down Expand Up @@ -543,153 +541,6 @@ set(AER_LIBRARIES
${CMAKE_DL_LIBS})

set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES})
if(SKBUILD) # Terra Addon build
add_subdirectory(qiskit_aer/backends/wrappers)
else() # Standalone build
set(AER_LIBRARIES
${AER_LIBRARIES}
${THRUST_DEPENDANT_LIBS}
${MPI_DEPENDANT_LIBS})

function(build_cuda target src_file is_exec)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64")
if (NOT CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
# We build SIMD filed separately, because they will be reached only if the
# machine running the code has SIMD support
set(SIMD_SOURCE_FILE "${PROJECT_SOURCE_DIR}/src/simulators/statevector/qv_avx2.cpp")
endif()
endif()
set_source_files_properties(${SIMD_SOURCE_FILE} PROPERTIES LANGUAGE CUDA)
set_source_files_properties(${src_file} PROPERTIES LANGUAGE CUDA)
set_source_files_properties(${src_file} PROPERTIES COMPILE_FLAGS "${CUDA_NVCC_FLAGS}")
if(DEFINED SIMD_FLAGS_LIST)
nvcc_add_compiler_options_list("${SIMD_FLAGS_LIST}" SIMD_FLAGS)
set_source_files_properties(${SIMD_SOURCE_FILE} PROPERTIES COMPILE_FLAGS "${CUDA_NVCC_FLAGS} ${SIMD_FLAGS}")
endif()
if(${is_exec})
add_executable(${target} ${src_file} ${SIMD_SOURCE_FILE})
else()
add_library(${target} ${src_file} ${SIMD_SOURCE_FILE})
endif()
target_link_libraries(${target} ${AER_LIBRARIES})
string(STRIP ${AER_COMPILER_FLAGS} AER_COMPILER_FLAGS_STRIPPED)
nvcc_add_compiler_options(${AER_COMPILER_FLAGS_STRIPPED} AER_COMPILER_FLAGS_OUT)

set_target_properties(${target} PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 14
COMPILE_FLAGS ${AER_COMPILER_FLAGS_OUT}
LINK_FLAGS ${AER_LINKER_FLAGS}
RUNTIME_OUTPUT_DIRECTORY_DEBUG Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE Release)
endfunction()

function(build_rocm target src_file is_exec)
# ROCm is only supported in x86_64 devices so it should be safe to leverage AVX2.
set(SIMD_SOURCE_FILE "${PROJECT_SOURCE_DIR}/src/simulators/statevector/qv_avx2.cpp")

set_source_files_properties(
${SIMD_SOURCE_FILE}
${src_file}
PROPERTIES LANGUAGE CXX)

if(${is_exec})
add_executable(${target} ${src_file} ${SIMD_SOURCE_FILE})
else()
add_library(${target} ${src_file} ${SIMD_SOURCE_FILE})
endif()

target_compile_options(${target} PRIVATE ${ROCM_EXTRA_FLAGS} ${SIMD_FLAGS_LIST})
target_compile_definitions(${target} PRIVATE ${ROCM_EXTRA_DEFS} ${AER_COMPILER_DEFINITIONS})

target_link_libraries(${target} PRIVATE ${AER_LIBRARIES})

set_target_properties(${target} PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 14
COMPILE_FLAGS ${AER_COMPILER_FLAGS}
LINK_FLAGS ${AER_LINKER_FLAGS}
RUNTIME_OUTPUT_DIRECTORY_DEBUG Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE Release)
endfunction()

function(build_cpu target src_file is_exec)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64")
if (NOT CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
# We build SIMD filed separately, because they will be reached only if the
# machine running the code has SIMD support
set(SIMD_SOURCE_FILE "${PROJECT_SOURCE_DIR}/src/simulators/statevector/qv_avx2.cpp")
endif()
endif()
string(REPLACE ";" " " SIMD_FLAGS "${SIMD_FLAGS_LIST}")
set_source_files_properties(${SIMD_SOURCE_FILE} PROPERTIES COMPILE_FLAGS "${SIMD_FLAGS}")
if(${is_exec})
add_executable(${target} ${src_file} ${SIMD_SOURCE_FILE})
else()
add_library(${target} SHARED ${src_file} ${SIMD_SOURCE_FILE})
endif()
target_link_libraries(${target} PRIVATE ${AER_LIBRARIES})
set_target_properties(${target} PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 14
COMPILE_FLAGS ${AER_COMPILER_FLAGS}
LINK_FLAGS ${AER_LINKER_FLAGS}
RUNTIME_OUTPUT_DIRECTORY_DEBUG Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE Release)

target_include_directories(${target}
PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR}
PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
target_compile_definitions(${target}
PRIVATE ${AER_COMPILER_DEFINITIONS})
if(WIN32 AND NOT AER_BLAS_LIB_PATH)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BACKEND_REDIST_DEPS}
$<TARGET_FILE_DIR:${target}>)
install(FILES ${BACKEND_REDIST_DEPS} DESTINATION bin)
endif()
endfunction()

# build qasm_simulator
set(AER_SIMULATOR_SOURCE "${PROJECT_SOURCE_DIR}/contrib/standalone/qasm_simulator.cpp")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(CUDA_FOUND AND AER_THRUST_BACKEND STREQUAL "CUDA")
build_cuda(qasm_simulator ${AER_SIMULATOR_SOURCE} TRUE)
elseif(HIP_FOUND AND AER_THRUST_BACKEND STREQUAL "ROCM")
build_rocm(qasm_simulator ${AER_SIMULATOR_SOURCE} TRUE)
else()
build_cpu(qasm_simulator ${AER_SIMULATOR_SOURCE} TRUE)
endif()

install(TARGETS qasm_simulator DESTINATION bin)
add_subdirectory(qiskit_aer/backends/wrappers)

if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(AER_RUNTIME_SOURCE "${PROJECT_SOURCE_DIR}/contrib/runtime/aer_runtime.cpp")
if(CUDA_FOUND AND AER_THRUST_BACKEND STREQUAL "CUDA")
build_cuda(aer ${AER_RUNTIME_SOURCE} FALSE)
elseif(HIP_FOUND AND AER_THRUST_BACKEND STREQUAL "ROCM")
build_rocm(aer ${AER_RUNTIME_SOURCE} FALSE)
else()
build_cpu(aer ${AER_RUNTIME_SOURCE} FALSE)
endif()
install(TARGETS aer)

# Tests
if(BUILD_TESTS AND NOT AER_MPI)
add_executable(test_libaer "${PROJECT_SOURCE_DIR}/test/runtime/runtime_sample.c")
target_include_directories(test_libaer PUBLIC "${PROJECT_SOURCE_DIR}/contrib/runtime/")
# AER_LINKER_FLAGS carry eventual OpenMP linking flags.
set_target_properties(test_libaer PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE bin
LINK_FLAGS ${AER_LINKER_FLAGS})
target_link_libraries(test_libaer PRIVATE ${AER_LIBRARIES})
target_link_libraries(test_libaer PRIVATE aer)
add_test(NAME aer_runtime_test COMMAND bin/test_libaer)
endif()
endif()

endif()

# Tests
if(BUILD_TESTS)
add_subdirectory(test)
endif()
Loading
Loading