在C ++ / CUDA中带有3个尖括号(<<<))的模板化方法是什么? [英] What are templated methods in C++ / CUDA with 3 angle brackets (<<<)?
问题描述
请原谅一个简单的问题,我的C ++生锈了。我正在使用C进行机器学习应用程序,该应用程序使用CUDA进行一些计算,并且找到了以下代码行。
Forgive what may be a simple question, my C++ is rusty. I'm working on a machine learning application in C that uses CUDA for some calculations, and I've found the following line of code.
很好奇如何解析它。它看起来像是模板化的方法,但是我不理解<<<三重括号。
Just curious how to parse this. It looks like a templated method, but I dont understand the triple angle-brackets '<<<'. What's going on here?
backward_scale_kernel<<<n, BLOCK>>>(x_norm, delta, batch, n, size, scale_updates);
对于上下文 n作为函数参数传入,我找不到BLOCK的位置
For context "n" is passed in as a function parameter, and I can't find where BLOCK is defined or assigned.
推荐答案
我确定已经有很好的副本,但是<<< >>>
装饰器,您看到的是CUDA运行时API 语法扩展,它允许指定CUDA内核调用的执行参数。
I'm sure there is a good duplicate for this already, but the <<< >>>
decorator you are seeing is a CUDA runtime API syntax extension which allows the execution parameters of a CUDA kernel call to be specified.
完整语法为
kernel_function<<<grid dimensions, block dimensions, dynamic shared memory, stream ID>>>( ....arguments....)
CUDA运行时API前端将此语法扩展为一对内联函数调用编译器发出的样板代码,以允许在运行时启动基础GPU内核。
The CUDA runtime API front end expands this syntax into a pair of inline function calls to compiler emitted boilerplate to allow the underlying GPU kernel to be launched at runtime.
这篇关于在C ++ / CUDA中带有3个尖括号(<<<))的模板化方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!