Skip to content

Commit

Permalink
new Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
KowerKoint committed Dec 14, 2023
1 parent a15a17f commit 18e3168
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/cpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ ENV PYTHONPATH="${PROJECT_DIR}/build:${PYTHONPATH}"
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-get update && \
apt-get install -y gcc-10 g++-10 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 \
apt-get install -y gcc-11 g++-11 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 \
&& apt-get install -y --no-install-recommends \
clang-format \
git \
Expand Down
17 changes: 11 additions & 6 deletions .devcontainer/gpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ ENV PYTHONPATH="${PROJECT_DIR}/build:${PYTHONPATH}"

RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update && \
apt-get install -y gcc-10 g++-10 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 \
apt-get install -y gcc-11 g++-11 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131, which is done in Microsoft's devcontainer image.
&& apt-get purge -y imagemagick imagemagick-6-common \
&& apt-get install -y --no-install-recommends \
ca-certificates \
clang-format \
cmake \
curl \
git \
gdb \
libboost-dev \
libpython3-dev \
manpages \
man-db \
ninja-build \
python3 \
python3-distutils \
Expand All @@ -37,6 +35,13 @@ RUN apt-get update && \
RUN pip install -U pip \
&& pip install black flake8 openfermion mypy pybind11-stubgen

RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-Linux-x86_64.sh -q -O /tmp/cmake-install.sh && \
chmod u+x /tmp/cmake-install.sh && \
mkdir /opt/cmake-3.28.0 && \
/tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.28.0 && \
rm /tmp/cmake-install.sh && \
ln -s /opt/cmake-3.28.0/bin/* /usr/local/bin

RUN git clone --recursive https://github.com/kokkos/kokkos.git /tmp/kokkos --depth 1 && \
mkdir /tmp/kokkos/build && \
cd /tmp/kokkos/build && \
Expand Down
72 changes: 36 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.21)

project(qulacs)

Expand All @@ -21,13 +21,47 @@ endif(NOT DEFINED QULACS_USE_TEST)
message(STATUS "QULACS_USE_PYTHON = ${QULACS_USE_PYTHON}")
message(STATUS "QULACS_USE_TEST = ${QULACS_USE_TEST}")

### Compile Warnings ###
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(WARNING_CPP "-Wall -Wdate-time -Wendif-labels -Werror=format=2 \
-Werror=missing-declarations -Werror=return-type -Wextra \
-Wfloat-equal -Wimplicit-fallthrough=5 -Wlogical-op \
-Wmissing-include-dirs -Wpointer-arith -Wredundant-decls \
-Wshadow -Wstrict-aliasing=2 -Wsuggest-attribute=noreturn -Wwrite-strings \
-fdiagnostics-color=auto -fstrict-aliasing")
# -Werror=undef is eliminated due to conflict with boost
elseif ((${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))
set(WARNING_CPP "-Wall -Wdate-time -Wendif-labels -Werror=format=2 \
-Werror=missing-declarations -Werror=return-type -Wextra \
-Wfloat-equal -Wimplicit-fallthrough \
-Wmissing-include-dirs -Wpointer-arith -Wredundant-decls \
-Wshadow -Wstrict-aliasing=2 -Wwrite-strings \
-fdiagnostics-color=auto -fstrict-aliasing")
endif()

### Compiler options ###
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Enable pthread
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

# Enable openmp
if(QULACS_USE_OMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
add_compile_definitions(OPENMP)
endif()
endif()

### Kokkos options ###
set(Kokkos_ENABLE_SERIAL Yes)
if(QULACS_USE_OMP)
set(Kokkos_ENABLE_OPENMP Yes)
endif(QULACS_USE_OMP)
if(QULACS_USE_CUDA)
set(Kokkos_ENABLE_CUDA Yes)
set(Kokkos_ARCH_VOLTA70 Yes)
find_program(CUDA_NVCC_EXECUTABLE nvcc)
if(CUDA_NVCC_EXECUTABLE)
set(CMAKE_CUDA_COMPILER_WRAPPER ${CUDA_NVCC_EXECUTABLE})
Expand All @@ -42,7 +76,7 @@ endif(QULACS_USE_CUDA)
FetchContent_Declare(
kokkos_fetch
GIT_REPOSITORY https://github.com/kokkos/kokkos
GIT_TAG 4.1.00
GIT_TAG 4.2.00
)
FetchContent_GetProperties(kokkos_fetch)
if(NOT kokkos_fetch_POPULATED)
Expand Down Expand Up @@ -96,40 +130,6 @@ else()
message(STATUS "Skip downloding googletest")
endif(QULACS_USE_TEST)

### Compile Warnings ###
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(WARNING_CPP "-Wall -Wdate-time -Wendif-labels -Werror=format=2 \
-Werror=missing-declarations -Werror=return-type -Wextra \
-Wfloat-equal -Wimplicit-fallthrough=5 -Wlogical-op \
-Wmissing-include-dirs -Wpointer-arith -Wredundant-decls \
-Wshadow -Wstrict-aliasing=2 -Wsuggest-attribute=noreturn -Wwrite-strings \
-fdiagnostics-color=auto -fstrict-aliasing")
# -Werror=undef is eliminated due to conflict with boost
elseif ((${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))
set(WARNING_CPP "-Wall -Wdate-time -Wendif-labels -Werror=format=2 \
-Werror=missing-declarations -Werror=return-type -Wextra \
-Wfloat-equal -Wimplicit-fallthrough \
-Wmissing-include-dirs -Wpointer-arith -Wredundant-decls \
-Wshadow -Wstrict-aliasing=2 -Wwrite-strings \
-fdiagnostics-color=auto -fstrict-aliasing")
endif()

### Compiler options ###
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang"))

add_compile_options("-std=c++20")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Enable pthread
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

# Enable openmp
if(QULACS_USE_OMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
add_compile_definitions(OPENMP)
endif()
endif()

### Add subdirectories ###
add_subdirectory(qulacs)
if(QULACS_USE_PYTHON)
Expand Down
2 changes: 1 addition & 1 deletion qulacs/state/state_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ double StateVector::compute_squared_norm() const {
Kokkos::parallel_reduce(
this->_dim,
KOKKOS_CLASS_LAMBDA(const UINT& it, double& tmp) {
tmp += std::norm(this->_amplitudes[it]);
tmp += Kokkos::norm2(this->_amplitudes[it]);
},
norm);
return norm;
Expand Down

0 comments on commit 18e3168

Please sign in to comment.