Skip to content

activate_custom_mpi.sh: do not link against mlir #2905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions runtime/cudaq/distributed/builtin/activate_custom_mpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ if [ -z "${CXX}" ]; then
fi
fi

extra_flags=""
if [[ "$CXX" == *nvq++* ]]; then
extra_flags="--disable-cudaq-links"
fi

echo "Using $CXX to build the MPI plugin for MPI installation in $MPI_PATH."
lib_mpi_plugin="$this_file_dir/libcudaq_distributed_interface_mpi.so"
$CXX -shared -std=c++17 -fPIC \
$extra_flags \
-I"${MPI_PATH}/include" \
-I"$this_file_dir" \
"$this_file_dir/mpi_comm_impl.cpp" \
Expand Down
28 changes: 20 additions & 8 deletions tools/nvqpp/nvq++.in
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ function show_help {
--execution-manager=<mgr> | -em=<mgr> | -execution-manager=<mgr>
Set the execution manager to <mgr>.

--disable-cudaq-links
Disable linking to cudaq libraries.

--disable-mlir-links
Disable linking to cudaq-mlir-runtime and cudaq-builder.

Expand Down Expand Up @@ -303,7 +306,8 @@ LIBRARY_MODE_EXECUTION_MANAGER="default"
PLATFORM_LIBRARY="default"
LLVM_QUANTUM_TARGET="qir"
LINKDIRS="-L${install_dir}/lib -L${install_dir}/lib/plugins @CUDAQ_CXX_NVQPP_LINK_STR@"
LINKLIBS="-lcudaq -lcudaq-common -lcudaq-ensmallen -lcudaq-nlopt -lcudaq-operator"
LINKLIBS=""
CUDAQ_LINKLIBS="-lcudaq -lcudaq-common -lcudaq-ensmallen -lcudaq-nlopt -lcudaq-operator"

# Add any plugin libraries to the link stage
CUDAQ_PLUGIN_DIR=${install_dir}/lib/plugins
Expand All @@ -313,7 +317,7 @@ if [ -d "$CUDAQ_PLUGIN_DIR" ] && [ -n "$(ls -A $CUDAQ_PLUGIN_DIR)" ]; then
PLUGIN_NAME=$(basename $entry)
PLUGIN_NAME=${PLUGIN_NAME#lib}
PLUGIN_NAME=${PLUGIN_NAME%@CMAKE_SHARED_LIBRARY_SUFFIX@}
LINKLIBS="$LINKLIBS -l$PLUGIN_NAME"
CUDAQ_LINKLIBS="$CUDAQ_LINKLIBS -l$PLUGIN_NAME"
done
fi

Expand All @@ -339,6 +343,7 @@ ENABLE_AGGRESSIVE_EARLY_INLINE=true
ENABLE_LOWER_TO_CFG=true
ENABLE_APPLY_SPECIALIZATION=true
ENABLE_LAMBDA_LIFTING=true
ENABLE_CUDAQ_LIB_LINKING=true
ENABLE_MLIR_LIB_LINKING=true
DELETE_TEMPS=true
TARGET_CONFIG=
Expand Down Expand Up @@ -456,6 +461,9 @@ while [ $# -ne 0 ]; do
--emulate | -emulate)
CUDAQ_EMULATE_REMOTE=true
;;
--disable-cudaq-links | -disable-cudaq-links)
ENABLE_CUDAQ_LIB_LINKING=false
;;
--disable-mlir-links | -disable-mlir-links)
ENABLE_MLIR_LIB_LINKING=false
;;
Expand Down Expand Up @@ -483,11 +491,11 @@ while [ $# -ne 0 ]; do
PLATFORM_LIBRARY="${arg#*=}"
;;
--load | -load)
LINKLIBS="${LINKLIBS} -lcudaq-$2"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} -lcudaq-$2"
shift
;;
--load=* | -load=*)
LINKLIBS="${LINKLIBS} -lcudaq-${arg#*=}"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} -lcudaq-${arg#*=}"
;;
-g)
COMPILER_FLAGS="${COMPILER_FLAGS} -g"
Expand Down Expand Up @@ -666,15 +674,19 @@ NVQIR_LIBS="${NVQIR_LIBS}${NVQIR_SIMULATION_BACKEND}"

# Add the MLIR-related libraries if requested.
if ${ENABLE_MLIR_LIB_LINKING}; then
LINKLIBS="${LINKLIBS} -lcudaq-mlir-runtime -lcudaq-builder"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} -lcudaq-mlir-runtime -lcudaq-builder"
fi

# Set the execution manager and the platform
LINKLIBS="${LINKLIBS} -lcudaq-em-${LIBRARY_MODE_EXECUTION_MANAGER}"
LINKLIBS="${LINKLIBS} -lcudaq-platform-${PLATFORM_LIBRARY}"
LINKLIBS="${LINKLIBS} ${NVQIR_LIBS}"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} -lcudaq-em-${LIBRARY_MODE_EXECUTION_MANAGER}"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} -lcudaq-platform-${PLATFORM_LIBRARY}"
CUDAQ_LINKLIBS="${CUDAQ_LINKLIBS} ${NVQIR_LIBS}"
LLC=${LLVMBIN}llc${llvm_suffix}

if ${ENABLE_CUDAQ_LIB_LINKING}; then
LINKLIBS="${LINKLIBS} ${CUDAQ_LINKLIBS}"
fi

if ${LIBRARY_MODE}; then
PREPROCESSOR_DEFINES="${PREPROCESSOR_DEFINES} -D CUDAQ_LIBRARY_MODE"
ENABLE_KERNEL_EXECUTION=false
Expand Down