diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 3e999558f4..29e56b42da 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -16,8 +16,8 @@ # SOURCE_DIR : the directory that SOURCE_LOCATION is relative to (if not the default) # LAUNCH_COMMAND : the command to launch the test (e.g., mpirun) function(add_nvqpp_test TEST_NAME SOURCE_LOCATION) - cmake_parse_arguments(PARSED_ARGS "" "TARGET;LABELS;SOURCE_DIR;LAUNCH_COMMAND;APPLICATION_ARGS;TARGET_OPTION" "" ${ARGN}) - set(NVQPP_COMPILE_ARGS "") + cmake_parse_arguments(PARSED_ARGS "" "TARGET;LABELS;SOURCE_DIR;LAUNCH_COMMAND;APPLICATION_ARGS;TARGET_OPTION" "" ${ARGN}) + set(NVQPP_COMPILE_ARGS "--library-mode ") if(PARSED_ARGS_TARGET) set(NVQPP_COMPILE_ARGS "${NVQPP_COMPILE_ARGS} --target ${PARSED_ARGS_TARGET}") if (PARSED_ARGS_TARGET_OPTION) diff --git a/docs/sphinx/applications/cpp/grover.cpp b/docs/sphinx/applications/cpp/grover.cpp index 2dac99fbdb..b4ac751ffd 100644 --- a/docs/sphinx/applications/cpp/grover.cpp +++ b/docs/sphinx/applications/cpp/grover.cpp @@ -1,6 +1,6 @@ // Compile and run with: // ``` -// nvq++ grover.cpp -o grover.x && ./grover.x +// nvq++ --library-mode grover.cpp -o grover.x && ./grover.x // ``` #include diff --git a/docs/sphinx/targets/cpp/photonics.cpp b/docs/sphinx/targets/cpp/photonics.cpp index bc69ee66be..521ace318b 100644 --- a/docs/sphinx/targets/cpp/photonics.cpp +++ b/docs/sphinx/targets/cpp/photonics.cpp @@ -1,6 +1,6 @@ // Compile and run with: // ``` -// nvq++ --target orca-photonics photonics.cpp +// nvq++ --library-mode --target orca-photonics photonics.cpp // ./a.out // ``` @@ -24,4 +24,4 @@ int main() { auto state = cudaq::get_state(photonicsKernel{}); state.dump(); -} \ No newline at end of file +} diff --git a/scripts/validate_container.sh b/scripts/validate_container.sh index 0e5116ebae..9e260c4dc8 100644 --- a/scripts/validate_container.sh +++ b/scripts/validate_container.sh @@ -150,6 +150,10 @@ do if [ -n "$intended_target" ]; then echo "Intended for execution on $intended_target backend." fi + use_library_mode=`sed -e '/^$/,$d' $ex | grep -oP '^//\s*nvq++.+-library-mode'` + if [ -n "$use_library_mode" ]; then + nvqpp_extra_options="--library-mode" + fi for t in $requested_backends do @@ -214,7 +218,7 @@ do for (( i=0; i<${arraylength}; i++ )); do echo " Testing nvidia target option: ${optionArray[$i]}" - nvq++ $ex $target_flag --target-option "${optionArray[$i]}" + nvq++ $nvqpp_extra_options $ex $target_flag --target-option "${optionArray[$i]}" if [ ! $? -eq 0 ]; then let "failed+=1" echo " :x: Compilation failed for $filename." >> "${tmpFile}_$(echo $t | tr - _)" @@ -235,7 +239,7 @@ do rm a.out /tmp/cudaq_validation.out &> /dev/null done else - nvq++ $ex $target_flag + nvq++ $nvqpp_extra_options $ex $target_flag if [ ! $? -eq 0 ]; then let "failed+=1" echo ":x: Compilation failed for $filename." >> "${tmpFile}_$(echo $t | tr - _)" diff --git a/targettests/Remote-Sim/compile_errors.cpp b/targettests/Remote-Sim/compile_errors.cpp index dee5a84739..3e91835930 100644 --- a/targettests/Remote-Sim/compile_errors.cpp +++ b/targettests/Remote-Sim/compile_errors.cpp @@ -8,7 +8,7 @@ // REQUIRES: remote-sim // clang-format off -// RUN: nvq++ %cpp_std --target remote-mqpu %s 2>&1 | FileCheck %s +// RUN: nvq++ --library-mode %cpp_std --target remote-mqpu %s 2>&1 | FileCheck %s // clang-format on #include diff --git a/targettests/Remote-Sim/nested_vectors.cpp b/targettests/Remote-Sim/nested_vectors.cpp index 1cad829b7f..29020d584e 100644 --- a/targettests/Remote-Sim/nested_vectors.cpp +++ b/targettests/Remote-Sim/nested_vectors.cpp @@ -8,7 +8,7 @@ // REQUIRES: remote-sim // clang-format off -// RUN: nvq++ %cpp_std --target remote-mqpu %s -o %t && %t +// RUN: nvq++ --library-mode %cpp_std --target remote-mqpu %s -o %t && %t // clang-format on #include "remote_test_assert.h" diff --git a/targettests/Remote-Sim/unsupport_args.cpp b/targettests/Remote-Sim/unsupport_args.cpp index 98a04bb217..3273456061 100644 --- a/targettests/Remote-Sim/unsupport_args.cpp +++ b/targettests/Remote-Sim/unsupport_args.cpp @@ -9,7 +9,7 @@ // REQUIRES: remote-sim // clang-format off -// RUN: nvq++ %cpp_std --target remote-mqpu %s 2>&1 | FileCheck %s +// RUN: nvq++ --library-mode %cpp_std --target remote-mqpu %s |& FileCheck %s // clang-format on #include diff --git a/targettests/execution/state_preparation_vector.cpp b/targettests/execution/state_preparation_vector.cpp index e95b068518..90408e79c0 100644 --- a/targettests/execution/state_preparation_vector.cpp +++ b/targettests/execution/state_preparation_vector.cpp @@ -7,7 +7,7 @@ ******************************************************************************/ // Simulators -// RUN: nvq++ %cpp_std --enable-mlir %s -o %t && %t | FileCheck %s +// RUN: nvq++ %cpp_std %s -o %t && %t | FileCheck %s // Quantum emulators // RUN: nvq++ %cpp_std -target quantinuum -emulate %s -o %t && \ diff --git a/tools/nvqpp/nvq++.in b/tools/nvqpp/nvq++.in index 187593a8bd..ad218ac5b7 100644 --- a/tools/nvqpp/nvq++.in +++ b/tools/nvqpp/nvq++.in @@ -376,7 +376,7 @@ fi # We default to LIBRARY_MODE, physical # Quantum Targets can override this to turn on # our MLIR compilation workflow. -LIBRARY_MODE=true +LIBRARY_MODE=false CXX=${LLVMBIN}clang++${llvm_suffix} TARGET_ARGS=() @@ -506,6 +506,9 @@ while [ $# -ne 0 ]; do --enable-mlir) LIBRARY_MODE=false ;; + --library-mode) + LIBRARY_MODE=true + ;; --clang-verbose | -clang-verbose) CLANG_VERBOSE="-v" ;;