Skip to content

Commit

Permalink
Removed old comment
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkusiak97 committed Oct 30, 2024
1 parent 3870eef commit 8f547cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
14 changes: 0 additions & 14 deletions src/blas/backends/cublas/cublas_scope_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ According to NVIDIA:
http://docs.nvidia.com/cuda/cublas/index.html#thread-safety2changeme
3) It is neither required nor recommended that different handles be used for different streams on the same device,
using the same host thread.
However, the 3 above advises are for using cuda runtime API. The NVIDIA runtime API creates a default context for users.
The createHandle function in cuBLAS uses the context located on top of the stack for each thread. Then, the cuBLAS routine
uses this context for resource allocation/access. Calling a cuBLAS function with a handle created for context A and
memories/queue created for context B results in a segmentation fault. Thus we need to create one handle per context
and per thread. A context can have multiple streams, so the important thing here is to have one cublasHandle per driver
context and that cuBLAS handle can switch between multiple streams created for that context. Here, we are dealing with
CUDA driver API, therefore, the SYCL-CUDA backend controls the context. If a queue(equivalent of CUDA stream) is associated
with a context different from the one on top of the thread stack(can be any context which associated at any time by either
the runtime or user for any specific reason), the context associated with the queue must be moved on top of the stack
temporarily for the requested routine operations. However, after the cuBLAS routine execution, the original context must
be restored to prevent intervening with the original user/runtime execution set up. Here, the RAII type context switch
is used to guarantee to recover the original CUDA context. The cuBLAS handle allocates internal resources, therefore,
the handle must be destroyed when the context goes out of scope. This will bind the life of cuBLAS handle to the SYCL context.
**/

class CublasScopedContextHandler {
Expand Down
4 changes: 2 additions & 2 deletions src/blas/backends/cublas/cublas_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace cublas {
template <typename H, typename F>
static inline void host_task_internal(H& cgh, sycl::queue queue, F f) {
cgh.hipSYCL_enqueue_custom_operation([f, queue](sycl::interop_handle ih) {
auto sc = CublasScopedContextHandler(queue, ih);
auto sc = CublasScopedContextHandler(ih);
f(sc);
});
}
Expand All @@ -60,7 +60,7 @@ static inline void host_task_internal(H& cgh, sycl::queue queue, F f) {
#else
cgh.host_task([f, queue](sycl::interop_handle ih) {
#endif
auto sc = CublasScopedContextHandler(queue, ih);
auto sc = CublasScopedContextHandler(ih);
f(sc);
});
}
Expand Down

0 comments on commit 8f547cd

Please sign in to comment.