Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Apr 12, 2024
1 parent aed4495 commit 1b00711
Show file tree
Hide file tree
Showing 9 changed files with 1,340 additions and 6 deletions.
48 changes: 48 additions & 0 deletions cmake/support_pllgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,51 @@ macro(findCustatevec external_libs)
target_link_libraries(${external_libs} INTERFACE custatevec)
endif()
endmacro()

# Macro to aid in finding cuStateVec lib
macro(findCutensornet external_libs)
find_library(CUTENSORNET_LIB
NAMES libcutensornet.so.2
HINTS /usr/lib
/usr/local/cuda
/usr/local/lib
/opt
/opt/cuda
lib
lib64
${CUQUANTUM_SDK}/lib
${CUQUANTUM_SDK}/lib64
${CUDAToolkit_LIBRARY_DIR}
${CUDA_TOOLKIT_ROOT_DIR}/lib
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${Python_SITELIB}/cuquantum/lib
ENV LD_LIBRARY_PATH
)

find_file( CUTENSORNET_INC
NAMES cutensornet.h
HINTS /usr/include
/usr/local/cuda
/usr/local/include
/opt
/opt/cuda
include
${CUQUANTUM_SDK}/include
${CUDAToolkit_INCLUDE_DIRS}
${CUDA_TOOLKIT_ROOT_DIR}/include
${Python_SITELIB}/cuquantum/include
ENV CPATH
)

if(NOT CUTENSORNET_LIB OR NOT CUTENSORNET_INC)
message(FATAL_ERROR "\nUnable to find cuQuantum SDK installation. Please ensure it is correctly installed and available on path.")
else()
add_library( cutensornet SHARED IMPORTED GLOBAL)

get_filename_component(CUTENSORNET_INC_DIR ${CUTENSORNET_INC} DIRECTORY)
target_include_directories(cutensornet INTERFACE ${CUTENSORNET_INC_DIR})
set_target_properties( cutensornet PROPERTIES IMPORTED_LOCATION ${CUTENSORNET_LIB})

target_link_libraries(${external_libs} INTERFACE cutensornet)
endif()
endmacro()
5 changes: 5 additions & 0 deletions pennylane_lightning/core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ set(COMPONENT_SUBDIRS algorithms
simulators
utils
)
if("${PL_BACKEND}" STREQUAL "lightning_tensor")
add_subdirectory(simulators)
add_subdirectory(utils)
else()
foreach(COMP ${COMPONENT_SUBDIRS})
add_subdirectory(${COMP})
endforeach()
endif()

if (BUILD_TESTS)
# Include macros supporting tests.
Expand Down
2 changes: 2 additions & 0 deletions pennylane_lightning/core/src/simulators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.20)

project(lightning_simulators LANGUAGES CXX)

if(NOT "${PL_BACKEND}" STREQUAL "lightning_tensor")
add_subdirectory(base)
endif()

###############################################################################
# Determine simulator and include its directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ findCUDATK(lightning_compile_options)

add_library(${PL_BACKEND}_utils INTERFACE)
target_include_directories(${PL_BACKEND}_utils INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(${PL_BACKEND}_utils INTERFACE CUDA::cudart CUDA::cublas CUDA::cusparse lightning_compile_options)
target_link_libraries(${PL_BACKEND}_utils INTERFACE CUDA::cudart CUDA::cublas CUDA::cusparse lightning_compile_options)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.21)
set(LOGO [=[
░█░░░▀█▀░█▀▀░█░█░▀█▀░█▀█░▀█▀░█▀█░█▀▀░░░░█▀▀░█▀█░█░█
░█░░░░█░░█░█░█▀█░░█░░█░█░░█░░█░█░█░█░░░░█░█░█▀▀░█░█
░▀▀▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░▀░░▀▀▀░▀░░░▀▀▀
]=])
message(${LOGO})

project(${PL_BACKEND}
DESCRIPTION "Lightning-Tensor bindings for PennyLane. Backed by NVIDIA cuQuantum SDK."
LANGUAGES CXX C CUDA
)

include("${pennylane_lightning_SOURCE_DIR}/cmake/support_pllgpu.cmake")
findCUDATK(lightning_external_libs)
findCutensornet(lightning_external_libs)

target_compile_options(lightning_compile_options INTERFACE "-D_ENABLE_PLTENSOR=1")


#########################
## Set Default Options ##
#########################

add_executable(test_tensor_explore test.cpp)

target_link_libraries(test_tensor_explore PRIVATE lightning_utils lightning_compile_options lightning_external_libs)
Loading

0 comments on commit 1b00711

Please sign in to comment.