Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有一条指令可以计算 a 的所有组件的总和float4,例如在 OpenCL 中?
float4
float4 v; float desiredResult = v.x + v.y + v.z + v.w;
float4 v; float desiredResult = dot(v, (float4)(1.0f, 1.0f, 1.0f, 1.0f));
这需要更多的工作,因为您在添加之前将每个组件乘以一个,但是有些 GPU 内置了点积指令。所以可能会更快;可能会慢一些。这取决于您的硬件。