NAMD
Public Member Functions | Static Public Attributes | List of all members
RunWithAffinity Class Reference

#include <GlobalGPUMgr.h>

Public Member Functions

 RunWithAffinity (const bool valid, const int tempCpu)
 
 ~RunWithAffinity ()
 

Static Public Attributes

static constexpr int kCudaOffset = 0
 
static constexpr int kNvshmemOffset = 1
 
static constexpr int kNcclOffset = 2
 

Detailed Description

Definition at line 30 of file GlobalGPUMgr.h.

Constructor & Destructor Documentation

◆ RunWithAffinity()

RunWithAffinity::RunWithAffinity ( const bool  valid,
const int  tempCpu 
)

Definition at line 20 of file GlobalGPUMgr.C.

20  {
21  validCpu = valid && (tempCpu >= 0) && (tempCpu < CmiNumCores());
22 
23  if (validCpu) {
24  current = CPU_ALLOC(CmiNumCores());
25  temp = CPU_ALLOC(CmiNumCores());
26  size = CPU_ALLOC_SIZE(CmiNumCores());
27 
28  CPU_ZERO_S(size, current);
29  CPU_ZERO_S(size, temp);
30 
31  pthread_getaffinity_np(pthread_self(), size, current);
32 
33  CPU_SET_S(tempCpu, size, temp);
34  pthread_setaffinity_np(pthread_self(), size, temp);
35  }
36 }

◆ ~RunWithAffinity()

RunWithAffinity::~RunWithAffinity ( )

Definition at line 38 of file GlobalGPUMgr.C.

38  {
39  if (validCpu) {
40  pthread_setaffinity_np(pthread_self(), size, current);
41 
42  CPU_FREE(current);
43  CPU_FREE(temp);
44  }
45 }

Member Data Documentation

◆ kCudaOffset

constexpr int RunWithAffinity::kCudaOffset = 0
static

Definition at line 36 of file GlobalGPUMgr.h.

◆ kNcclOffset

constexpr int RunWithAffinity::kNcclOffset = 2
static

Definition at line 38 of file GlobalGPUMgr.h.

◆ kNvshmemOffset

constexpr int RunWithAffinity::kNvshmemOffset = 1
static

Definition at line 37 of file GlobalGPUMgr.h.


The documentation for this class was generated from the following files: