Skip to content

Commit

Permalink
Merge pull request #239 from alxhotel/refactor-folders
Browse files Browse the repository at this point in the history
Rename folders
  • Loading branch information
imranashraf authored Jun 19, 2019
2 parents 0beb732 + 3898ad0 commit 7b70eb8
Show file tree
Hide file tree
Showing 69 changed files with 173 additions and 168 deletions.
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Build files
build
cbuild
dist
openql.egg-info
lab
env

# Temp files
*.dot
*.qc
*.dat
Expand All @@ -14,8 +17,9 @@ lab
*.pyd
*.pyc
*.cache
openql/openql.py
*/test_output/*
tests/cc/test_output
swig/openql.py
swig/openql/openql.py

# Test files
test_output
.ipynb_checkpoints
doc/notebooks/test_output
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ SET(CLI11_INCLUDE_DIRS

## These are the include directories used by the compiler.
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}
${LEMON_INCLUDE_DIRS}
${CLI11_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src
)

IF(CMAKE_COMPILER_IS_GNUCXX)
Expand All @@ -52,14 +52,14 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)

IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11 /MP /D_USE_MATH_DEFINES")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11 /MP /D_USE_MATH_DEFINES")
ENDIF(MSVC)

IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wall -Wfatal-errors -ggdb")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -Wall -Wfatal-errors -Wno-unused-local-typedef -ggdb")
ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

ADD_SUBDIRECTORY(programs)
ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(openql)
ADD_SUBDIRECTORY(swig)
12 changes: 6 additions & 6 deletions Jenkinsfile-master
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pipeline {
agent any
environment {
PERSIST_WORKSPACE = ""
}
PERSIST_WORKSPACE = ""
}

stages {
stage('Checkout eQASM_Assembler'){
stage('Checkout eQASM_Assembler') {
steps {
script {
PERSIST_WORKSPACE = WORKSPACE
Expand All @@ -15,7 +15,7 @@ pipeline {
sh 'GIT_SSH_COMMAND="ssh -i /var/jenkins_home/.ssh/jenkins_eqasm_assembler_deploy" git clone [email protected]:QE-Lab/eQASM_Assembler.git'
}
}
stage('Checkout libqasm'){
stage('Checkout libqasm') {
steps {
script {
PERSIST_WORKSPACE = WORKSPACE
Expand All @@ -35,10 +35,10 @@ pipeline {
steps {
dir(PERSIST_WORKSPACE) {
sh 'pwd'
sh 'rm -Rf cbuild'
sh 'rm -rf cbuild'
sh 'mkdir cbuild'
sh 'cd cbuild/ && cmake .. && make'
sh 'rm -Rf env'
sh 'rm -rf env'
sh 'python3 -m venv env'
sh '''
. ./env/bin/activate &&
Expand Down
12 changes: 6 additions & 6 deletions Jenkinsfile-v2.2.0
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pipeline {
agent any
environment {
PERSIST_WORKSPACE = ""
}
PERSIST_WORKSPACE = ""
}

stages {
stage('Checkout eQASM_Assembler'){
stage('Checkout eQASM_Assembler') {
steps {
script {
PERSIST_WORKSPACE = WORKSPACE
Expand All @@ -15,7 +15,7 @@ pipeline {
sh 'GIT_SSH_COMMAND="ssh -i /var/jenkins_home/.ssh/jenkins_eqasm_assembler_deploy" git clone --branch v2.2.0 [email protected]:QE-Lab/eQASM_Assembler.git'
}
}
stage('Checkout libqasm'){
stage('Checkout libqasm') {
steps {
script {
PERSIST_WORKSPACE = WORKSPACE
Expand All @@ -35,10 +35,10 @@ pipeline {
steps {
dir(PERSIST_WORKSPACE) {
sh 'pwd'
sh 'rm -Rf cbuild'
sh 'rm -rf cbuild'
sh 'mkdir cbuild'
sh 'cd cbuild/ && cmake .. && make'
sh 'rm -Rf env'
sh 'rm -rf env'
sh 'python3 -m venv env'
sh '''
. ./env/bin/activate &&
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.md
include programs/*.py
include tests/*.py
include examples/*.py
include tests/*.py
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ In all the instructions below, `python` refers to `Python 3` and `pip` refers to

Openql can be installed as a conda package (currently on Linux and Windows) by:

```
```sh
conda install -c imran.ashraf openql
```

## use recipe to build package locally

conda packages can also be built locally by using the recipie available in `conda-recipe` directory, by running the following command:

```
```sh
conda build conda-recipe/.
```

The generated package can then be installed by:

```
```sh
conda install openql --use-local
```

Expand All @@ -73,27 +73,27 @@ conda install openql --use-local

N.B. the instructions below will compile the C++ files the first time you try to install OpenQL package. If you are updating an existing installation you should first clean and recompile the C++ files using the following command.

```
```sh
python cleanme.py
```

## Linux, Windows & OSX

Running the following command in Terminal/Power Shell should install the openql package:

```
```sh
python setup.py install --user
```

Or

```
```sh
pip install -e .
```

By defining NPROCS=N environment variable, multiple processos can be created for faster compilation. For example, the following command will create 4 processes for compilation:

```
```sh
NPROCS=4 python setup.py install --user
```

Expand All @@ -102,13 +102,13 @@ NPROCS=4 python setup.py install --user

In order to pass all the tests, `qisa-as` and `libqasm` should be installed first. Follow [qisa-as](https://github.com/QE-Lab/eQASM_Assembler) and [libqasm](https://github.com/QE-Lab/libqasm) instructions to install python interfaces of these modules. Once `qisa-as` and `libqasm` are installed, you can run all the tests by:

```
```sh
py.test -v
```

Or

```
```sh
python -m pytest
```

Expand All @@ -120,18 +120,18 @@ Existing tests and programs can be compiled by the following instructions. You c

## Linux/OSX

```
mkdir cbuild
cd OpenQL/cbuild
```sh
mkdir cbuild
cd cbuild
cmake .. # generates the make file based on CMakeLists.txt in the OpenQL directory
make # compiles the source code into the current directory.
```

To execute an example program go to e.g., `OpenQL/cbuild/programs` and execute one of the files e.g., `./simple`. The output will be saved to the output directory next to the file.
To execute an example program go to e.g., `OpenQL/cbuild/examples` and execute one of the files e.g., `./simple`. The output will be saved to the output directory next to the file.

If one wants to compile and run a single file, e.g., `example.cc`, to compile it one can run :

```
```sh
mkdir output # create an output directory if it does not exist
g++ -std=c++11 example.cc -o example.exe -I OpenQL/ # compile the file
./example.exe # execute the file
Expand All @@ -140,25 +140,26 @@ g++ -std=c++11 example.cc -o example.exe -I OpenQL/ # compile the file
## Windows

```
cd OpenQL/cbuild
mkdir cbuild
cd cbuild
cmake -G "NMake Makefiles" ..
nmake
```

## Usage

Example C++ tests and programs can be found in 'tests' and 'programs'
directories. Executables for these will be generated in 'build/tests' and 'build/programs'
Example C++ tests and programs can be found in 'tests' and 'examples'
directories. Executables for these will be generated in 'build/tests' and 'build/examples'
directory.

Example python tests and programs can be found in the 'tests' and 'programs' directories.
Example python tests and programs can be found in the 'tests' and 'examples' directories.
These can be executed as 'python tests/simplePyTest.py'.

# Getting started

After installing OpenQL a good place to get started is by looking at the files
in the "tests" directory. Here you can find commented examples on how to use OpenQL.
For instance, `programs/getting_started.py` could be a good starting point.
For instance, `examples/getting_started.py` could be a good starting point.
`doc` directory as well as the Wiki page documents various aspects.

N.B. gates in OpenQL are *case insensitive*.
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package:
version: "0.7.0"

source:
# use the following path for the source if this recipie is inside the repo
# use the following path for the source if this recipe is inside the repo
path: ../.

# otherwise, use the following to get source
Expand Down
18 changes: 9 additions & 9 deletions programs/CMakeLists.txt → examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/programs
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/examples
${PROJECT_SOURCE_DIR}/tests
)

Expand All @@ -20,15 +20,15 @@ INCLUDE_DIRECTORIES(
# TARGET_LINK_LIBRARIES(multi_qubits_randomized_benchmarking ${LEMON_LIBRARIES} )

# create output directory for test outputs
ADD_CUSTOM_TARGET(programs-output-directory ALL
ADD_CUSTOM_TARGET(examples-output-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory test_output)

# copy configuration files
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/test_cfg_cbox.json
test_cfg_cbox.json COPYONLY)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/test_cfg_cbox.json
test_cfg_cbox.json COPYONLY)

CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/hardware_config_cc_light.json
hardware_config_cc_light.json COPYONLY)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/hardware_config_cc_light.json
hardware_config_cc_light.json COPYONLY)

CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/hardware_config_qx.json
hardware_config_qx.json COPYONLY)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/tests/hardware_config_qx.json
hardware_config_qx.json COPYONLY)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <time.h>

#include <ql/openql.h>
#include <openql.h>

// clifford inverse lookup table for grounded state
const size_t inv_clifford_lut_gs[] = {0, 2, 1, 3, 8, 10, 6, 11, 4, 9, 5, 7, 12, 16, 23, 21, 13, 17, 18, 19, 20, 15, 22, 14};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <time.h>

#include <ql/openql.h>
#include <openql.h>

// clifford inverse lookup table for grounded state
const size_t inv_clifford_lut_gs[] = {0, 2, 1, 3, 8, 10, 6, 11, 4, 9, 5, 7, 12, 16, 23, 21, 13, 17, 18, 19, 20, 15, 22, 14};
Expand Down
2 changes: 1 addition & 1 deletion programs/rb_single.cc → examples/rb_single.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <time.h>

#include <ql/openql.h>
#include <openql.h>

// clifford inverse lookup table for grounded state
const size_t inv_clifford_lut_gs[] = {0, 2, 1, 3, 8, 10, 6, 11, 4, 9, 5, 7, 12, 16, 23, 21, 13, 17, 18, 19, 20, 15, 22, 14};
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion programs/simple.cc → examples/simple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <time.h>

#include <ql/openql.h>
#include <openql.h>

int main(int argc, char ** argv)
{
Expand Down
21 changes: 12 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from sys import platform

rootDir = os.path.dirname(os.path.realpath(__file__))
srcDir = os.path.join(rootDir, "ql")
srcDir = os.path.join(rootDir, "src")
buildDir = os.path.join(rootDir, "cbuild")
clibDir = os.path.join(buildDir, "openql")
clibDir = os.path.join(buildDir, "swig")

nprocs = 1
env_var_nprocs = os.environ.get('NPROCS')
if(env_var_nprocs != None):
if (env_var_nprocs != None):
nprocs = int(env_var_nprocs)

print('Using {} processes for compilation'.format(nprocs))
Expand Down Expand Up @@ -59,11 +59,13 @@
else:
print('Unknown/Unsupported OS !!!')

genclib = os.path.join(clibDir, clibname)
clib = os.path.join(rootDir, "openql", clibname)
copyfile(genclib, clib)
clib = os.path.join(clibDir, clibname)
swigDir = os.path.join(rootDir, "swig", "openql")
clibSwig = os.path.join(swigDir, clibname)

copyfile(clib, clibSwig)
copyfile(os.path.join(clibDir, "openql.py"),
os.path.join(rootDir, "openql", "openql.py"))
os.path.join(swigDir, "openql.py"))
os.chdir(rootDir)


Expand Down Expand Up @@ -117,8 +119,9 @@ def read(fname):
author='Nader Khammassi and Imran Ashraf',
author_email='[email protected], [email protected]',
url='https://github.com/QE-Lab/OpenQL',
license=read('license'),
license=read('LICENSE'),
packages=['openql'],
package_dir={'': 'swig'},
include_package_data=True,
package_data={'openql': [clib]},
package_data={'openql': [clibSwig]},
zip_safe=False)
Loading

0 comments on commit 7b70eb8

Please sign in to comment.