This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
125 lines (106 loc) · 4.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
PYTHON3 := $(shell which python3 2>/dev/null)
PYTHON := python3
COVERAGE := --cov=pennylane_lightning_gpu --cov-report term-missing --cov-report=html:coverage_html_report
TESTRUNNER := -m pytest tests --tb=short
MPILAUNCHER := mpirun
NUMPROCS := 2
MPITESTRUNNER := -m pytest mpitests --tb=short
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " install to install PennyLane-Lightning-GPU"
@echo " wheel to build the PennyLane-Lightning-GPU wheel"
@echo " dist to package the source distribution"
@echo " clean to delete all temporary, cache, and build files"
@echo " clean-docs to delete all built documentation"
@echo " test to run the test suite"
@echo " test-cpp to run the C++ test suite"
@echo " test-python to run the Python test suite"
@echo " coverage to generate a coverage report"
@echo " format [check=1] to apply C++ and Python formatter; use with 'check=1' to check instead of modify (requires black and clang-format)"
@echo " format [version=?] to apply C++ and Python formatter; use with 'version={version}' to check or modify with clang-format-{version} instead of clang-format"
@echo " check-tidy to build PennyLane-Lightning-GPU with ENABLE_CLANG_TIDY=ON (requires clang-tidy & CMake)"
.PHONY: install
install:
ifndef CUQUANTUM_SDK
@echo "Please ensure the CUQUANTUM variable is assigned to the cuQuantum SDK path"
@test $(CUQUANTUM_SDK)
endif
ifndef PYTHON3
@echo "To install PennyLane-Lightning-GPU you must have Python 3.9+ installed."
endif
$(PYTHON) setup.py build_ext --cuquantum=$(CUQUANTUM_SDK) --verbose
$(PYTHON) setup.py install
.PHONY: wheel
wheel:
$(PYTHON) setup.py bdist_wheel
.PHONY: dist
dist:
$(PYTHON) setup.py sdist
.PHONY : clean
clean:
$(PYTHON) setup.py clean --all
rm -rf pennylane_lightning_gpu/__pycache__
rm -rf pennylane_lightning_gpu/src/__pycache__
rm -rf tests/__pycache__
rm -rf pennylane_lightning_gpu/src/tests/__pycache__
rm -rf dist
rm -rf build
rm -rf BuildTests Build
rm -rf .coverage coverage_html_report/
rm -rf tmp
rm -rf *.dat
rm -rf pennylane_lightning_gpu/lightning_gpu_qubit_ops*
docs:
make -C doc html
.PHONY : clean-docs
clean-docs:
rm -rf doc/code/api
make -C doc clean
.PHONY : test-python test-builtin test-suite
test-python: test-builtin test-suite
test-python-mpi:
$(MPILAUNCHER) -np $(NUMPROCS) $(PYTHON) $(MPITESTRUNNER)
test-builtin:
$(PYTHON) -I $(TESTRUNNER)
test-suite:
pl-device-test --device lightning.gpu --skip-ops --shots=20000
pl-device-test --device lightning.gpu --shots=None --skip-ops
test-cpp:
ifndef CUQUANTUM_SDK
@echo "Please ensure the CUQUANTUM variable is assigned to the cuQuantum SDK path"
@test $(CUQUANTUM_SDK)
endif
rm -rf ./BuildTests
cmake . -BBuildTests -G Ninja -DBUILD_TESTS=1 -DPLLGPU_BUILD_TESTS=1 -DCUQUANTUM_SDK=$(CUQUANTUM_SDK)
cmake --build ./BuildTests
./BuildTests/pennylane_lightning_gpu/src/tests/runner_gpu
test-cpp-mpi:
rm -rf ./BuildTests
cmake . -BBuildTests -G Ninja -DBUILD_TESTS=1 -DPLLGPU_BUILD_TESTS=1 -DPLLGPU_ENABLE_MPI=On -DCUQUANTUM_SDK=$(CUQUANTUM_SDK)
cmake --build ./BuildTests
$(MPILAUNCHER) -np $(NUMPROCS) ./BuildTests/pennylane_lightning_gpu/src/tests/mpi_runner
coverage:
@echo "Generating coverage report..."
$(PYTHON) $(TESTRUNNER) $(COVERAGE)
pl-device-test --device lightning.gpu --skip-ops --shots=20000 $(COVERAGE) --cov-append
pl-device-test --device lightning.gpu --shots=None --skip-ops $(COVERAGE) --cov-append
.PHONY: format format-cpp format-python
format: format-cpp format-python
format-cpp:
ifdef check
./bin/format --check --cfversion $(if $(version:-=),$(version),0) pennylane_lightning_gpu/src ./tests
else
./bin/format --cfversion $(if $(version:-=),$(version),0) pennylane_lightning_gpu/src ./tests
endif
format-python:
ifdef check
black -l 100 ./pennylane_lightning_gpu ./tests ./mpitests --check
else
black -l 100 ./pennylane_lightning_gpu ./tests ./mpitests
endif
.PHONY: check-tidy
check-tidy:
rm -rf ./Build
cmake . -BBuild -G Ninja -DENABLE_CLANG_TIDY=ON -DBUILD_TESTS=1
cmake --build ./Build