Skip to content

Commit

Permalink
optimization in cmake files + renaming/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanbrand committed Jul 22, 2024
1 parent 0f10a80 commit 80faf61
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 52 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/.vscode

# Build
sim_qasm
test_wgt_storage
/build
*.so
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ x q[0];
measure q[0]->c[0];
measure q[1]->c[1];
```
This code can be found in [`qasm/circuits/bell_state.qasm`](qasm/circuits/bell_state.qasm) and can be run with `./build/qasm/sim_qasm qasm/circuits/bell_state.qasm`. All gates specified in [qelib1.inc](https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/qasm/libs/qelib1.inc) are supported, as well as measurements. Custom definitions of gates and classical conditioning are currently not supported.
This code can be found in [`qasm/circuits/bell_state.qasm`](qasm/circuits/bell_state.qasm) and can be run with `./build/qasm/run_qasm_on_qmdd qasm/circuits/bell_state.qasm`. All gates specified in [qelib1.inc](https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/qasm/libs/qelib1.inc) are supported, as well as measurements. Custom definitions of gates and classical conditioning are currently not supported.


## Documentation
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ add_example(test_algs test_algs.c)
target_sources(test_algs PRIVATE ${ALGORITHM_EXAMPLES})

add_executable(circuit_equivalence circuit_equivalence.c)
target_link_libraries(circuit_equivalence qsylvan qsylvan_qasm_parser_qmdd)
target_link_libraries(circuit_equivalence qsylvan qsylvan_qasm_parser)
2 changes: 1 addition & 1 deletion examples/circuit_equivalence.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <time.h>
#include <sys/time.h>
#include <qsylvan.h>
#include "../qasm/simple_parser.h"
#include "../qasm/qsylvan_qasm_parser.h"

#define max(a,b) ((a > b) ? a : b)

Expand Down
54 changes: 11 additions & 43 deletions qasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,18 @@
#set(SOURCES
# QASM_to_circuit.c
# circuit.c
#)
#add_executable(test_circuit test_circuit.c ${SOURCES})
#target_link_libraries(test_circuit qsylvan)
#add_executable(qsylvan_qasm qsylvan_qasm.c ${SOURCES})
#target_link_libraries(qsylvan_qasm qsylvan popt)

# allow the parser to be included in other places as a library
# (without compiling eval_expr.cpp again)

#add_library(qsylvan_qasm_parser)
#target_sources(qsylvan_qasm_parser
# PRIVATE
# simple_parser.cpp
# parse_math/eval_expr.cpp
# PUBLIC
# simple_parser.h)
#
#add_executable(sim_qasm sim_qasm.c)
#target_link_libraries(sim_qasm qsylvan qsylvan_qasm_parser)


# QASM simulator with qmddd

add_library(qsylvan_qasm_parser_qmdd)
target_sources(qsylvan_qasm_parser_qmdd
# 1. Compile qasm parser as separate library
# (to allow the parser to be included in other places as a library, without
# compiling eval_expr.cpp again)
add_library(qsylvan_qasm_parser)
target_sources(qsylvan_qasm_parser
PRIVATE
simple_parser.cpp
qsylvan_qasm_parser.cpp
parse_math/eval_expr.cpp
PUBLIC
simple_parser.h)
qsylvan_qasm_parser.h)

# 2. QMDD QASM simulator
add_executable(run_qasm_on_qmdd run_qasm_on_qmdd.c)
target_link_libraries(run_qasm_on_qmdd qsylvan qsylvan_qasm_parser_qmdd)


# QASM simulator with mtbdd

add_library(qsylvan_qasm_parser_mtbdd)
target_sources(qsylvan_qasm_parser_mtbdd
PRIVATE
simple_parser.cpp
parse_math/eval_expr.cpp
PUBLIC
simple_parser.h)
target_link_libraries(run_qasm_on_qmdd qsylvan qsylvan_qasm_parser)

# 3. MTBDD QASM simulator
add_executable(run_qasm_on_mtbdd run_qasm_on_mtbdd.c)
target_link_libraries(run_qasm_on_mtbdd qsylvan qsylvan_qasm_parser_mtbdd)
target_link_libraries(run_qasm_on_mtbdd qsylvan qsylvan_qasm_parser)
2 changes: 1 addition & 1 deletion qasm/simple_parser.cpp → qasm/qsylvan_qasm_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <stdio.h>
#include <string.h>

#include "simple_parser.h"
#include "qsylvan_qasm_parser.h"
#include "parse_math/eval_expr.hpp"

/**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion qasm/run_qasm_on_mtbdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <qsylvan_gates_mtbdd_mpc.h>

#include <sylvan_mpc.h>
#include "simple_parser.h" // TODO: rename in qsylvan_qasm_parser.h
#include "qsylvan_qasm_parser.h"

/**
*
Expand Down
2 changes: 1 addition & 1 deletion qasm/run_qasm_on_qmdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <sys/time.h>

#include "qsylvan.h"
#include "simple_parser.h"
#include "qsylvan_qasm_parser.h"

/**********************<Arguments (configured via argp)>***********************/

Expand Down
4 changes: 2 additions & 2 deletions qasm/test/test_sim_qasm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Testing running sim_qasm from command line.
Testing running qmdd qasm simulator from command line.
"""
import os
import subprocess
Expand Down Expand Up @@ -39,7 +39,7 @@ def get_vector(qasm_file : str, args : list):
['--reorder'], ['--reorder-swap']])
class TestCircuits:
"""
Test sim_qasm on all given circuits, with CL arguments given above.
Test on all given circuits, with CL arguments given above.
"""

def test_adder_n4(self, cl_args : str):
Expand Down

0 comments on commit 80faf61

Please sign in to comment.