Skip to content

Commit

Permalink
Make nvq++ --version work (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhowe23 authored Sep 21, 2023
1 parent 5624924 commit 7e55ee7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 11 additions & 0 deletions test/NVQPP/testVersion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*******************************************************************************
* Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// Note: change |& to 2>&1| if running in bash
// RUN: nvq++ --version |& FileCheck %s
// CHECK: nvq++ Version
6 changes: 2 additions & 4 deletions tools/cudaq-quake/cudaq-quake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ int main(int argc, char **argv) {
// Process the command-line options, including reading in a file.
[[maybe_unused]] llvm::InitLLVM unused(argc, argv);
cl::ParseCommandLineOptions(argc, argv, toolName);
if (showVersion)
llvm::errs() << "nvq++ Version " << cudaq::getVersion() << '\n';
ErrorOr<std::unique_ptr<MemoryBuffer>> fileOrError =
MemoryBuffer::getFileOrSTDIN(inputFilename);
if (auto ec = fileOrError.getError()) {
Expand Down Expand Up @@ -341,10 +343,6 @@ int main(int argc, char **argv) {
<< '\n';
});

if (showVersion) {
llvm::errs() << "nvq++ Version " << cudaq::getVersion() << '\n';
}

// Process arguments.
std::vector<std::string> clArgs = {"-std=c++20", "-resource-dir",
resourceDirPath.string()};
Expand Down
9 changes: 9 additions & 0 deletions tools/nvqpp/nvq++.in
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ SRCS=
ARGS=
CUDAQ_QUAKE_ARGS=
DO_LINK=true
SHOW_VERSION=false
ENABLE_DEVICE_CODE_LOADERS=true
ENABLE_KERNEL_EXECUTION=true
ENABLE_AGGRESSIVE_EARLY_INLINE=true
Expand Down Expand Up @@ -386,6 +387,7 @@ while [ $# -ne 0 ]; do
;;
--version)
CUDAQ_QUAKE_ARGS="--nvqpp-version ${CUDAQ_QUAKE_ARGS}"
SHOW_VERSION=true
;;
-v)
ECHO=true
Expand Down Expand Up @@ -506,6 +508,13 @@ fi

OPT_PASSES="builtin.module(${OPT_PASSES})"

if ${SHOW_VERSION} && [ -z "$SRCS" ] && [ -z "$OBJS" ]; then
# If version is requested and no source files were provided, bypass the
# cudaq-quake path that expects to read code from stdin.
echo "" | ${TOOLBIN}cudaq-quake ${CUDAQ_QUAKE_ARGS}
DO_LINK=false
fi

for i in ${SRCS}; do
file=$(basename -s .cc -s .cpp $i)

Expand Down

0 comments on commit 7e55ee7

Please sign in to comment.