forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hip] Set the current device before calls into Hip. (iree-org#19103)
This is a bit of a brute-force way to solve our main hip multi-device problems temporarily until the more complete fix is in place. For the single-device case this has negligible performance implications as `hipCtxSetCurrent` is a no-op in that case. For the multi-device case this could cause more significant performance problems if the user program swaps between devices within a thread. --------- Signed-off-by: Andrew Woloszyn <[email protected]> Signed-off-by: Giacomo Serafini <[email protected]>
- Loading branch information
1 parent
0618250
commit d5672c7
Showing
18 changed files
with
215 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef IREE_HAL_DRIVERS_HIP_CONTEXT_UTIL_H_ | ||
#define IREE_HAL_DRIVERS_HIP_CONTEXT_UTIL_H_ | ||
|
||
#include "iree/base/api.h" | ||
#include "iree/hal/drivers/hip/dynamic_symbols.h" | ||
#include "iree/hal/drivers/hip/status_util.h" | ||
|
||
static inline iree_status_t iree_hal_hip_set_context( | ||
const iree_hal_hip_dynamic_symbols_t* syms, hipCtx_t hip_context) { | ||
if (!hip_context) { | ||
return iree_ok_status(); | ||
} | ||
IREE_TRACE({ | ||
hipCtx_t current_context = NULL; | ||
IREE_HIP_RETURN_IF_ERROR(syms, hipCtxGetCurrent(¤t_context), | ||
"hipCtxGetCurrent"); | ||
if (current_context != hip_context) { | ||
IREE_TRACE_ZONE_BEGIN_NAMED(z0, "iree_hal_hip_set_context_switch"); | ||
iree_status_t status = | ||
IREE_HIP_RESULT_TO_STATUS(syms, hipCtxSetCurrent(hip_context)); | ||
IREE_TRACE_ZONE_END(z0); | ||
return status; | ||
} | ||
}); | ||
return IREE_HIP_RESULT_TO_STATUS(syms, hipCtxSetCurrent(hip_context)); | ||
} | ||
|
||
#endif // IREE_HAL_DRIVERS_HIP_CONTEXT_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.