-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split the implementation of the void interface into the definition of the interface, and its implementations on streams and graphs. * Add missing files * Check if a task implementation can match a prototype where the void_interface arguments are ignored * Implement ctx.abstract_logical_data() which relies on a void data interface * Illustrate how to use abstract handles in local contexts * Introduce an is_void_interface() virtual method in the data interface to potentially optimize some stages * Small improvements in the examples * Do not try to allocate or move void data * Do not use I as a variable * fix linkage error * rename abtract_logical_data into logical_token * Document logical token * fix spelling error * fix sphinx error * reflect name changes * use meaningful variable names * simplify logical_token implementation because writeback is already disabled * add a unit test for token elision * implement token elision in host_launch * Remove unused type * Implement helpers to check if a function can be invoked from a tuple, or from a tuple where we removed tokens * Much simpler is_tuple_invocable_with_filtered implementation * Fix buggy test * Factorize code * Document that we can ignore tokens for task and host_launch * Documentation for logical data freeze
- Loading branch information
Showing
16 changed files
with
625 additions
and
128 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
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
114 changes: 114 additions & 0 deletions
114
cudax/include/cuda/experimental/__stf/graph/interfaces/void_interface.cuh
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,114 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of CUDASTF in CUDA C++ Core Libraries, | ||
// 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 | ||
// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/** | ||
* @file | ||
* | ||
* @brief This implements a void data interface over the graph_ctx backend | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cuda/__cccl_config> | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
|
||
#include <cuda/experimental/__stf/graph/graph_data_interface.cuh> | ||
#include <cuda/experimental/__stf/internal/void_interface.cuh> | ||
|
||
namespace cuda::experimental::stf | ||
{ | ||
|
||
template <typename T> | ||
struct graphed_interface_of; | ||
|
||
/** | ||
* @brief Data interface to manipulate the void interface in the CUDA graph backend | ||
*/ | ||
class void_graph_interface : public graph_data_interface<void_interface> | ||
{ | ||
public: | ||
/// @brief Alias for the base class | ||
using base = graph_data_interface<void_interface>; | ||
/// @brief Alias for the shape type | ||
using base::shape_t; | ||
|
||
void_graph_interface(void_interface s) | ||
: base(mv(s)) | ||
{} | ||
void_graph_interface(shape_of<void_interface> s) | ||
: base(mv(s)) | ||
{} | ||
|
||
void data_allocate( | ||
backend_ctx_untyped&, | ||
block_allocator_untyped&, | ||
const data_place&, | ||
instance_id_t, | ||
::std::ptrdiff_t& s, | ||
void**, | ||
event_list&) override | ||
{ | ||
s = 0; | ||
} | ||
|
||
void data_deallocate( | ||
backend_ctx_untyped&, block_allocator_untyped&, const data_place&, instance_id_t, void*, event_list&) final | ||
{} | ||
|
||
cudaGraphNode_t graph_data_copy( | ||
cudaMemcpyKind, | ||
instance_id_t, | ||
instance_id_t, | ||
cudaGraph_t graph, | ||
const cudaGraphNode_t* input_nodes, | ||
size_t input_cnt) override | ||
{ | ||
cudaGraphNode_t dummy; | ||
cuda_safe_call(cudaGraphAddEmptyNode(&dummy, graph, input_nodes, input_cnt)); | ||
return dummy; | ||
} | ||
|
||
bool pin_host_memory(instance_id_t) override | ||
{ | ||
// no-op | ||
return false; | ||
} | ||
|
||
void unpin_host_memory(instance_id_t) override {} | ||
|
||
/* This helps detecting when we are manipulating a void data interface, so | ||
* that we can optimize useless stages such as allocations or copies */ | ||
bool is_void_interface() const override final | ||
{ | ||
return true; | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Define how the CUDA stream backend must manipulate this void interface | ||
* | ||
* Note that we specialize cuda::experimental::stf::shape_of to avoid ambiguous specialization | ||
* | ||
* @extends graphed_interface_of | ||
*/ | ||
template <> | ||
struct graphed_interface_of<void_interface> | ||
{ | ||
using type = void_graph_interface; | ||
}; | ||
|
||
} // end namespace cuda::experimental::stf |
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.