简体   繁体   English

将 __constant__ memory 与 MPI 和流一起使用

[英]Using __constant__ memory with MPI and streams

If I have a __constant__ value如果我有一个__constant__

__constant__ float constVal;

Which may or may not be initialized by MPI ranks on non-blocking streams:非阻塞流上的 MPI 等级可能会也可能不会初始化:

cudaMemcpyToSymbolAsync((void*)&constVal,deviceValue,sizeof(float),0,cudaMemcpyDeviceToDevice,stream);

Is this:这是:

  1. Safe to be accessed by multiple MPI ranks simultaneously within kernels?在内核中同时被多个 MPI 等级访问是否安全? Ie do ranks share the same instance of val or do MPI semantics (they all have a private copy) still hold?即,排名是否共享同一个val实例或 MPI 语义(它们都有一个私有副本)是否仍然有效?
  2. If the above is safe, is it safe to be initialized by multiple MPI ranks?如果以上是安全的,那么由多个 MPI rank 初始化是否安全?
  1. Safe to be accessed by multiple MPI ranks simultaneously within kernels?在内核中同时被多个 MPI 等级访问是否安全? Ie do ranks share the same instance of val or do MPI semantics (they all have a private copy) still hold?即,排名是否共享同一个 val 实例或 MPI 语义(它们都有一个私有副本)是否仍然有效?

Neither.两者都不。 CUDA contexts are not shared amongst processes. CUDA 上下文不在进程之间共享。 If you have multiple processes you get multiple contexts, and each context has its own copy of all the statically defined symbols and code.如果您有多个进程,您将获得多个上下文,并且每个上下文都有自己的所有静态定义的符号和代码的副本。 This behaviour is independent of MPI semantics.此行为独立于 MPI 语义。 If you are imagining that multiple processes in an MPI communicator are sharing the same GPU context and state, they aren't.如果您想象 MPI 通信器中的多个进程共享相同的 GPU 上下文和 state,那么它们不是。

  1. If the above is safe, is it safe to be initialized by multiple MPI ranks?如果以上是安全的,那么由多个 MPI rank 初始化是否安全?

It isn't only safe, it is mandatory.它不仅安全,而且是强制性的。

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

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