简体   繁体   English

cuda malloc 托管 memory 之后的新放置

[英]Placement new after cuda malloc managed memory

I have terrible errors with CUDA managed allocation. CUDA 托管分配存在严重错误。 I'd like to confirm that the following code is correct:我想确认以下代码是正确的:

T* x;
cudaMallocManaged(&x, sizeof(*x));
new(x) T(..)

Is placement new syntax supported by CUDA version 11. Thanks. CUDA 版本 11 是否支持放置新语法。谢谢。

yes, that should be usable, ignoring minor issues like the use of ellipsis and missing semicolon.是的,这应该是可用的,忽略诸如使用省略号和缺少分号之类的小问题。 You can find examples of proper and typical use of placement new in CUDA right here on the SO cuda tag with a bit of searching.您可以在此处的 SO cuda标签上找到正确和典型使用 CUDA 中新放置的示例,并进行一些搜索。

Yes, placement new is supported/usable.是的,支持/可用放置新。 The code you have depicted here is mostly host code (ignoring a call to a host code library).您在此处描述的代码主要是主机代码(忽略对主机代码库的调用)。 So the support for this operation (placement new) in the context you have shown is actually coming from the host compiler you are using, not anything provided by the CUDA toolkit.因此,在您显示的上下文中,对这个操作(新放置)的支持实际上来自您正在使用的主机编译器,而不是 CUDA 工具包提供的任何东西。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM