Skip to content

Commit d4f75f7

Browse files
v3.7.0
2 parents af22034 + 29824c7 commit d4f75f7

29 files changed

+2802
-1378
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

.github/workflows/llvm-asan.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

.github/workflows/macos-unit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

.github/workflows/ubuntu-unit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

.github/workflows/windows-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

.github/workflows/windows-unit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- develop
88
pull_request:
99
branches:
10-
- '**'
10+
- master
11+
- develop
1112

1213
jobs:
1314

AUTHORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Dr Mihai Duta [developer]
3333
original prototyping
3434

3535
External contributors:
36+
Jakub Adamski
37+
optimised distributed communication by sending max-size messages asynchronously
3638
Bruno Villasenor Alvarez on behalf of AMD
3739
ported the GPU backend to HIP, for AMD GPU compatibility
3840
Dr Nicolas Vogt on behalf of HQS Quantum Simulations

QuEST/CMakeLists.txt

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ option(USE_HIP "Whether to use HIP for GPU code compilation for AMD GPUs. Set to
3737

3838
set(GPU_ARCH gfx90 CACHE STRING "GPU hardware dependent, used for AMD GPUs when USE_HIP=1. Lookup at https://llvm.org/docs/AMDGPUUsage.html#amdgpu-processor-table. Write without fullstop")
3939

40+
option(USE_CUQUANTUM "Whether to use NVIDIA's cuQuantum library (requires prior installation) in lieu of QuEST's bespoke GPU kernel. Set to 1 to enable." 0)
41+
4042

4143
# *****************************************************************************
4244
# ***** NO CHANGES SHOULD BE REQUIRED FROM THE USER BEYOND THIS POINT *********
@@ -49,6 +51,7 @@ message(STATUS "OMP acceleration is ${MULTITHREADED}")
4951
message(STATUS "MPI distribution is ${DISTRIBUTED}")
5052
if (${GPUACCELERATED})
5153
message(STATUS "HIP compilation is ${USE_HIP}")
54+
message(STATUS "cuQuantum compilation is ${USE_CUQUANTUM}")
5255
endif()
5356

5457

@@ -119,25 +122,28 @@ endif()
119122
if (GPUACCELERATED)
120123
if (USE_HIP)
121124

122-
if(NOT DEFINED HIP_PATH)
123-
if(NOT DEFINED ENV{HIP_PATH})
124-
message(WARNING "WARNING: HIP_PATH is not defiend. Using default HIP_PATH=/opt/rocm/hip " ${HIP_VERSION})
125-
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
126-
else()
127-
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
125+
if(NOT DEFINED HIP_PATH)
126+
if(NOT DEFINED ENV{HIP_PATH})
127+
message(WARNING "WARNING: HIP_PATH is not defiend. Using default HIP_PATH=/opt/rocm/hip " ${HIP_VERSION})
128+
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
129+
else()
130+
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
131+
endif()
128132
endif()
129-
endif()
130133

131-
if(EXISTS "${HIP_PATH}")
132-
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
133-
find_package(HIP REQUIRED)
134-
message(STATUS "Found HIP: " ${HIP_VERSION})
135-
message(STATUS "HIP PATH: " ${HIP_PATH})
136-
endif()
137-
138-
ADD_DEFINITIONS( -DUSE_HIP )
139-
ADD_DEFINITIONS( -D__HIP_PLATFORM_AMD__ )
134+
if(EXISTS "${HIP_PATH}")
135+
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
136+
find_package(HIP REQUIRED)
137+
message(STATUS "Found HIP: " ${HIP_VERSION})
138+
message(STATUS "HIP PATH: " ${HIP_PATH})
139+
endif()
140+
141+
ADD_DEFINITIONS( -DUSE_HIP )
142+
ADD_DEFINITIONS( -D__HIP_PLATFORM_AMD__ )
140143

144+
elseif (USE_CUQUANTUM)
145+
find_package(CUDA REQUIRED)
146+
ADD_DEFINITIONS( -DUSE_CUQUANTUM )
141147
else()
142148
find_package(CUDA REQUIRED)
143149
endif()
@@ -280,7 +286,12 @@ endif()
280286
# ----- C++ COMPILER FLAGS --------------------------------------------------
281287

282288
# set C++ flags that are common between compilers and build types
283-
set (CMAKE_CXX_STANDARD 98)
289+
if (USE_CUQUANTUM)
290+
set(CMAKE_CXX_STANDARD 14)
291+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
292+
else ()
293+
set (CMAKE_CXX_STANDARD 98)
294+
endif ()
284295

285296
# Use -O2 for all but debug mode by default
286297
if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug"))
@@ -412,6 +423,14 @@ target_link_libraries(QuEST PUBLIC ${MPI_C_LIBRARIES})
412423
# ----- GPU -------------------------------------------------------------------
413424
if (USE_HIP)
414425
target_link_libraries(QuEST PUBLIC ${HIP_PATH}/lib/libamdhip64.so )
426+
elseif (USE_CUQUANTUM)
427+
find_library(CUQUANTUM_LIBRARIES custatevec)
428+
if (NOT CUQUANTUM_LIBRARIES)
429+
message(FATAL_ERROR "cuQuantum library (specifically custatevec) not found")
430+
endif ()
431+
432+
target_link_libraries(QuEST ${CUDA_LIBRARIES} ${CUQUANTUM_LIBRARIES})
433+
target_include_directories(QuEST PUBLIC "/usr/local/cuda/include")
415434
else()
416435
target_link_libraries(QuEST ${CUDA_LIBRARIES})
417436
endif()

QuEST/include/QuEST.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@
3434

3535
# include "QuEST_precision.h"
3636

37+
38+
39+
// ensure custatevecHandle_t is defined, even if no GPU
40+
# ifdef USE_CUQUANTUM
41+
# include <custatevec.h>
42+
typedef struct CuQuantumConfig {
43+
cudaMemPool_t cuMemPool;
44+
cudaStream_t cuStream;
45+
custatevecHandle_t cuQuantumHandle;
46+
custatevecDeviceMemHandler_t cuMemHandler;
47+
} CuQuantumConfig;
48+
# else
49+
# define CuQuantumConfig void*
50+
# endif
51+
52+
53+
3754
// prevent C++ name mangling
3855
#ifdef __cplusplus
3956
extern "C" {
@@ -368,6 +385,11 @@ typedef struct Qureg
368385
//! Storage for reduction of probabilities on GPU
369386
qreal *firstLevelReduction, *secondLevelReduction;
370387

388+
//! Storage for wavefunction amplitues and config (copy of QuESTEnv's handle) in cuQuantum deployment
389+
cuAmp* cuStateVec;
390+
cuAmp* deviceCuStateVec;
391+
CuQuantumConfig* cuConfig;
392+
371393
//! Storage for generated QASM output
372394
QASMLogger* qasmLog;
373395

@@ -386,6 +408,10 @@ typedef struct QuESTEnv
386408
int numRanks;
387409
unsigned long int* seeds;
388410
int numSeeds;
411+
412+
// a copy of the QuESTEnv's config, used only in cuQuantum deployment
413+
CuQuantumConfig* cuConfig;
414+
389415
} QuESTEnv;
390416

391417

@@ -4236,6 +4262,10 @@ qreal calcPurity(Qureg qureg);
42364262
* linear algebra calculation.
42374263
*
42384264
* The number of qubits represented in \p qureg and \p pureState must match.
4265+
*
4266+
* > In the GPU-accelerated cuQuantum backend, this function further assumes that
4267+
* > the density matrix \p qureg is correctly normalised, and otherwise returns the
4268+
* > fidelity of the conjugate-transpose of \p qureg.
42394269
*
42404270
* @see
42414271
* - calcHilbertSchmidtDistance()

QuEST/include/QuEST_precision.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@
1010
* @author Tyson Jones (doc)
1111
*/
1212

13-
# include <math.h>
14-
1513
# ifndef QUEST_PRECISION_H
1614
# define QUEST_PRECISION_H
1715

16+
# include <math.h>
17+
18+
19+
// define CUDA complex types as void if not using cuQuantum.
20+
// note we used cuComplex.h for complex numbers, in lieu of
21+
// Thrust's complex<qreal>, so that the QuEST.h header can
22+
// always be compiled with C99, rather than C++14.
23+
# ifdef USE_CUQUANTUM
24+
# include <cuComplex.h>
25+
# else
26+
# define cuFloatComplex void
27+
# define cuDoubleComplex void
28+
# endif
29+
1830

1931
// set default double precision if not set during compilation
2032
# ifndef QuEST_PREC
21-
# define QuEST_PREC 2
33+
# define QuEST_PREC 2
2234
# endif
2335

2436

@@ -28,6 +40,7 @@
2840
# if QuEST_PREC==1
2941
# define qreal float
3042
// \cond HIDDEN_SYMBOLS
43+
# define cuAmp cuFloatComplex
3144
# define MPI_QuEST_REAL MPI_FLOAT
3245
# define MPI_MAX_AMPS_IN_MSG (1LL<<29) // must be 2^int
3346
# define REAL_STRING_FORMAT "%.8f"
@@ -41,7 +54,8 @@
4154
*/
4255
# elif QuEST_PREC==2
4356
# define qreal double
44-
// \cond HIDDEN_SYMBOLS
57+
// \cond HIDDEN_SYMBOLS
58+
# define cuAmp cuDoubleComplex
4559
# define MPI_QuEST_REAL MPI_DOUBLE
4660
# define MPI_MAX_AMPS_IN_MSG (1LL<<28) // must be 2^int
4761
# define REAL_STRING_FORMAT "%.14f"
@@ -57,6 +71,7 @@
5771
# elif QuEST_PREC==4
5872
# define qreal long double
5973
// \cond HIDDEN_SYMBOLS
74+
# define cuAmp void // invalid
6075
# define MPI_QuEST_REAL MPI_LONG_DOUBLE
6176
# define MPI_MAX_AMPS_IN_MSG (1LL<<27) // must be 2^int
6277
# define REAL_STRING_FORMAT "%.17Lf"

0 commit comments

Comments
 (0)