简体   繁体   English

如何判断复制节点搜索是否失败,或者我的节点或图是否无效?

[英]How can I tell whether a copy-node search failed, or whether my node or graph are invalid?

Consider the CUDA graphs API function cuFindNodeInClone() .考虑 CUDA 图 API 函数cuFindNodeInClone() The documentation says, that it: 文件说,它:

Returns:退货:

CUDA_SUCCESS , CUDA_ERROR_INVALID_VALUE CUDA_SUCCESS , CUDA_ERROR_INVALID_VALUE

This seems problematic to me.这对我来说似乎有问题。 How can I tell whether the search failed (eg because there is no copy of the passed node in the graph), or whether the node or graph are simply invalid (eg nullptr)?我如何判断搜索是否失败(例如,因为图中没有传递节点的副本),或者节点或图是否只是无效的(例如,nullptr)? Does the second error value signify both?第二个错误值是否表示两者? Can I get a third error value which is just not mentioned?我可以得到第三个没有提到的错误值吗?

When using the runtime API, the returned node is nullptr if the original node does not exist in the cloned graph.使用运行时 API 时,如果克隆图中不存在原始节点,则返回的节点为 nullptr。 For nullptr original node or nullptr cloned graph, the output node is left unmodified.对于 nullptr 原始节点或 nullptr 克隆图,输出节点保持不变。


#include <iostream>
#include <cassert>

int main(){
    cudaError_t status;

    cudaGraph_t graph;
    status = cudaGraphCreate(&graph, 0);
    assert(status == cudaSuccess);

    cudaGraphNode_t originalNode;
    status = cudaGraphAddEmptyNode(&originalNode, graph, nullptr, 0);
    assert(status == cudaSuccess);

    cudaGraph_t graphclone;
    status = cudaGraphClone(&graphclone, graph);
    assert(status == cudaSuccess);

    cudaGraphNode_t anotherNode;
    status = cudaGraphAddEmptyNode(&anotherNode, graph, nullptr, 0);
    assert(status == cudaSuccess);

    cudaGraphNode_t nodeInClone = (cudaGraphNode_t)7;
    status = cudaGraphNodeFindInClone(&nodeInClone, originalNode, graphclone);
    std::cout << cudaGetErrorString(status) << " " << (void*)nodeInClone << "\n";

    nodeInClone = (cudaGraphNode_t)7;
    status = cudaGraphNodeFindInClone(&nodeInClone, nullptr, graphclone);
    std::cout << cudaGetErrorString(status) << " " << (void*)nodeInClone << "\n";

    nodeInClone = (cudaGraphNode_t)7;
    status = cudaGraphNodeFindInClone(&nodeInClone, originalNode, nullptr);
    std::cout << cudaGetErrorString(status) << " " << (void*)nodeInClone << "\n";

    nodeInClone = (cudaGraphNode_t)7;
    status = cudaGraphNodeFindInClone(&nodeInClone, anotherNode, graphclone);
    std::cout << cudaGetErrorString(status) << " " << (void*)nodeInClone << "\n";
}

On my machine with CUDA 11.8, this prints在我的 CUDA 11.8 机器上,打印

no error 0x555e3cf287c0
invalid argument 0x7
invalid argument 0x7
invalid argument 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在node.js上拆分参数,而不会为默认搜索创建错误 - How can I split my parameter on node.js without creating an error for a default search 如何编写一个 python 程序来判断输入的数字是否可以形成三角形? - how to write a python program that can tell whether the numbers entered can form a triangle or not? 我的 Flask 应用程序如何检查 SQLite3 事务是否正在进行中? - How can my Flask app check whether a SQLite3 transaction is in progress? 如何捕获Rust的swap_with_slice()vec方法中是否发生错误? - How can I capture whether an error occurred in Rust's swap_with_slice() vec method? 判断net.Listener是否已死 - Tell whether net.Listener is dead 如何判断我的代码执行的模块是什么? - How can I tell what module my code is executing in? 如何在此 node.js 应用程序的警报中获取我的 err.message? - How can I get my err.message in the alert for this node.js app? 如何调试节点模块? - How can I debug node modules? 如何检查DirectX是否可用? - How to check whether DirectX is available? 如何判断.Net System.Diagnostics.Process成功运行或失败? - How can I tell when .Net System.Diagnostics.Process ran successfully or failed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM