Skip to content

Commit

Permalink
Switch the default to enable mlir.
Browse files Browse the repository at this point in the history
Update the tests and the driver to make --enable-mlir the default. Add
a new option, --library-mode, to allow the user to select the old
default of library mode.

Add required command line argument to tests.

Repair the function definition as well.

The option is always ignored. Hardcode library-mode into
the add_nvqpp_test function instead.

Fix validation script to respect the compiler mode selected.

Signed-off-by: Eric Schweitz <[email protected]>
  • Loading branch information
schweitzpgi committed Nov 15, 2024
1 parent 3300b12 commit bdad400
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# SOURCE_DIR <DIR>: the directory that SOURCE_LOCATION is relative to (if not the default)
# LAUNCH_COMMAND <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)
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/applications/cpp/grover.cpp
Original file line number Diff line number Diff line change
@@ -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 <cmath>
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/targets/cpp/photonics.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Compile and run with:
// ```
// nvq++ --target orca-photonics photonics.cpp
// nvq++ --library-mode --target orca-photonics photonics.cpp
// ./a.out
// ```

Expand All @@ -24,4 +24,4 @@ int main() {

auto state = cudaq::get_state(photonicsKernel{});
state.dump();
}
}
8 changes: 6 additions & 2 deletions scripts/validate_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 - _)"
Expand All @@ -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 - _)"
Expand Down
2 changes: 1 addition & 1 deletion targettests/Remote-Sim/compile_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/Remote-Sim/nested_vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion targettests/Remote-Sim/unsupport_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cudaq.h>
Expand Down
2 changes: 1 addition & 1 deletion targettests/execution/state_preparation_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
5 changes: 4 additions & 1 deletion tools/nvqpp/nvq++.in
Original file line number Diff line number Diff line change
Expand Up @@ -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=()
Expand Down Expand Up @@ -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"
;;
Expand Down

0 comments on commit bdad400

Please sign in to comment.