Skip to content

Conversation

@kparzysz-quic
Copy link
Contributor

Allow users to override the selection via QAIC_PATH_OVERRIDE environment variable, for example on non-Ubuntu systems that can still run Ubuntu binaries.

Allow users to override the selection via QAIC_PATH_OVERRIDE
environment variable, for example on non-Ubuntu systems that
can still run Ubuntu binaries.
@kparzysz-quic
Copy link
Contributor Author

cc: @mehrdadh @supersat

Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

_qaic_path
)
set_parent(${_output_variable} "${_qaic_path}")
set(_override $ENV{QAIC_PATH_OVERRIDE})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be more idiomatic for QAIC_PATH_OVERRIDE to be a CMake variable, rather than an environment variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation for an environment variable is that one can set it and then use cmake as if nothing happened, so to speak. Since cmake calls itself recursively when building various projects, passing of a cmake variable would need to be explicit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.

_check_path_exists("${_qaic_path}" _qaic_path_found)
if(NOT _qaic_path_found)
message(
SEND_ERROR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason to use SEND_ERROR instead of FATAL_ERROR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a WARNING---the message is there to inform the user about the override flag.

- Remove repeated call to _check_path_exists.
- Return qaic_path-NOTFOUND is qaic is not found.
- Change SEND_ERROR to WARNING when qaic is not found, since not finding
  of other properties is not an error.
@cconvey
Copy link
Contributor

cconvey commented Apr 4, 2022

Thanks @kparzysz-quic ! There might be one last issue, but that's probably all:

Now when get_hexagon_sdk_property can't obtain a valid path for QAIC_EXE, some (all?) callers need to check for that condition.

It looks like that's already happening in some places, for example:

get_hexagon_sdk_property("${HEXAGON_SDK_ROOT}" "${HEXAGON_ARCH}"
SDK_INCLUDE SDK_INCLUDE_DIRS
QURT_INCLUDE QURT_INCLUDE_DIRS
DSPRPC_LIB DSPRPC_LIB_DIRS
RPCMEM_ROOT RPCMEM_ROOT_DIR
QAIC_EXE QAIC_EXE_PATH
)
if(NOT SDK_INCLUDE_DIRS OR NOT QURT_INCLUDE_DIRS OR NOT DSPRPC_LIB_DIRS OR
NOT RPCMEM_ROOT_DIR OR NOT QAIC_EXE_PATH)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

But not everywhere that (I think) relies on it being valid:

  • get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
    SDK_INCLUDE SDK_INCLUDE_DIRS
    QAIC_EXE QAIC_EXE_PATH
    )
    foreach(INCDIR IN LISTS SDK_INCLUDE_DIRS)
    list(APPEND QAIC_FLAGS "-I${INCDIR}")
    endforeach()
    add_custom_command(
    OUTPUT
    "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc.h"
    "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc_skel.c"
    "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc_stub.c"
    COMMAND
    ${QAIC_EXE_PATH} ${QAIC_FLAGS}
  • add_custom_command(
    OUTPUT ${LAUNCHER_RPC_STUB_C} ${LAUNCHER_RPC_H}
    COMMAND ${QAIC_EXE_PATH} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
    MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
    )
  • add_custom_command(
    OUTPUT ${LAUNCHER_RPC_SKEL_C} ${LAUNCHER_RPC_H}
    COMMAND ${QAIC_EXE_PATH} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
    MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
    )

@kparzysz-quic
Copy link
Contributor Author

Now when get_hexagon_sdk_property can't obtain a valid path for QAIC_EXE, some (all?) callers need to check for that condition.

All these checks do is display a warning. In case of a missing qaic, the warning is already shown in the property lookup itself.

@cconvey
Copy link
Contributor

cconvey commented Apr 4, 2022

Now when get_hexagon_sdk_property can't obtain a valid path for QAIC_EXE, some (all?) callers need to check for that condition.

All these checks do is display a warning. In case of a missing qaic, the warning is already shown in the property lookup itself.

Right. An earlier version of this PR would cause cmake to fail if the qaic executable couldn't be found.

The current version of this PR would only issue a warning during cmake execution, leaving the hard failure until the make invocation.

I've been assuming that when possible, we want to trap errors during cmake execution rather than waiting until make, ninja, etc. attempt to build those targets.

I'm not aware of TVM having a guideline about this, so if the other reviewers / committers are okay with it, that's fine.

@masahi masahi merged commit 2844654 into apache:main Apr 4, 2022
@kparzysz-quic kparzysz-quic deleted the hexagon-osrel-qaic branch April 4, 2022 22:13
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
* [Hexagon] Select qaic executable based on Ubuntu version

Allow users to override the selection via QAIC_PATH_OVERRIDE
environment variable, for example on non-Ubuntu systems that
can still run Ubuntu binaries.

* Address review comments

- Remove repeated call to _check_path_exists.
- Return qaic_path-NOTFOUND is qaic is not found.
- Change SEND_ERROR to WARNING when qaic is not found, since not finding
  of other properties is not an error.
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Apr 11, 2022
* [Hexagon] Select qaic executable based on Ubuntu version

Allow users to override the selection via QAIC_PATH_OVERRIDE
environment variable, for example on non-Ubuntu systems that
can still run Ubuntu binaries.

* Address review comments

- Remove repeated call to _check_path_exists.
- Return qaic_path-NOTFOUND is qaic is not found.
- Change SEND_ERROR to WARNING when qaic is not found, since not finding
  of other properties is not an error.
Lucien0 pushed a commit to Lucien0/tvm that referenced this pull request Apr 19, 2022
* [Hexagon] Select qaic executable based on Ubuntu version

Allow users to override the selection via QAIC_PATH_OVERRIDE
environment variable, for example on non-Ubuntu systems that
can still run Ubuntu binaries.

* Address review comments

- Remove repeated call to _check_path_exists.
- Return qaic_path-NOTFOUND is qaic is not found.
- Change SEND_ERROR to WARNING when qaic is not found, since not finding
  of other properties is not an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants