Skip to content

Commit

Permalink
Simulator dependency target, fix for Power architecture (#5)
Browse files Browse the repository at this point in the history
* new dependencies target (make depend) for the qasm-simulator-cpp

(cherry picked from commit 3b25390)

* changed to executable and bug fix

(cherry picked from commit ce8be89)

* assume yes for automatic pkg install

(cherry picked from commit 2cd7607)

* -march not supported on ppc64le. Use -mcpu instead

(cherry picked from commit 7cdab8f)

* bugfix

(cherry picked from commit 831692e)
  • Loading branch information
sathayen authored and ajavadia committed Apr 11, 2018
1 parent c58abbc commit 1977b24
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ sim:
make -C src/qasm-simulator-cpp/src clean
make -C src/qasm-simulator-cpp/src

# Build dependencies for the simulator target
depend:
make -C src/qasm-simulator-cpp depend

coverage_erase:
coverage erase

Expand Down
5 changes: 4 additions & 1 deletion src/qasm-simulator-cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ all: sim
sim:
make -C src

depend:
./build_dependencies.sh

clean:
make -C src clean
make -C src clean
46 changes: 46 additions & 0 deletions src/qasm-simulator-cpp/build_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# ------------------------------------------------------------------------------
# build_dependencies.sh
#
# Dependency installer for qiskit-sdk-py/src/qasm-simulator-cpp
# Running the script:
# 1. Run the script directly
# ./build_dependencies.sh
# 2. Alternatively, build the make depend target (See the Makefile)
# make depend
#
# .. note:: Tested on Ubuntu 16.04 only.
# ------------------------------------------------------------------------------
set -ex
os_type=`uname -s`

# Check who is the current user.
USER=$(whoami)

if [ ${USER} == "root" ]
then
SUDOCMD=""
else
SUDOCMD="sudo"
fi

# Check the OS Type
echo "OS is $os_type"

if [[ "$os_type" == "Darwin" ]]; then
${SUDOCMD} xcode-select --install
elif [[ "$os_type" == "Linux" ]]; then
echo "Installing dependencies on Linux"
linux_distro=`cat /etc/*release | grep "ID_LIKE=" | cut -c9- | tr -d '"'`
if [[ "$linux_distro" == "debian" ]]; then
${SUDOCMD} apt-get update
${SUDOCMD} apt-get -y install build-essential libblas-dev liblapack-dev
elif [[ "$linux_distro" == "fedora" ]]; then
${SUDOCMD} yum update
${SUDOCMD} yum -y install devtoolset-6 blas blas-devel lapack lapack-devel
${SUDOCMD} scl enable devtoolset-6 bash
else
echo "Unsupported linux distro: $linux_distro"
fi
fi
10 changes: 9 additions & 1 deletion src/qasm-simulator-cpp/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ OUTPUT_DIR = ../../../qiskit/backends
CC = g++

# Use Homebrew GNU g++ for enabling OpenMP on macOS

OS:=$(shell uname)
GCC7:=$(shell g++-7 --version | grep ^'command not found')
ifeq ($(OS)$(GCC7),Darwin)
CC = g++-7
endif

# -march not supported on ppc64le (Power). Use -mcpu instead
ARCH:=$(shell uname -m)
ifeq ($(ARCH),ppc64le)
OPT = -O3 -mcpu=native -ffast-math
endif

# Check if compiler is Apple LLVM and doesn't support OpenMP
APPLELLVM = $(shell ${CC} --version | grep ^Apple)
ifeq ($(APPLELLVM),)
Expand Down Expand Up @@ -48,6 +53,9 @@ sim: main.o
sim_debug: main.o
$(CC) -g $(CPPFLAGS) $(DEFINES) -o ${OUTPUT_DIR}/qasm_simulator_cpp_debug main.o $(LIBS)

depend:
../build_dependencies.sh

clean:
rm -rf ${OUTPUT_DIR}/qasm_simulator_cpp main.o

0 comments on commit 1977b24

Please sign in to comment.