Merge "Merge branch release-4-6"
[alexxy/gromacs.git] / src / gromacs / legacyheaders / types / hw_info.h
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
2  *
3  *
4  * This file is part of GROMACS.
5  * Copyright (c) 2012-
6  *
7  * Written by the Gromacs development team under coordination of
8  * David van der Spoel, Berk Hess, and Erik Lindahl.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * To help us fund GROMACS development, we humbly ask that you cite
16  * the research papers on the package. Check out http://www.gromacs.org
17  *
18  * And Hey:
19  * Gromacs Runs On Most of All Computer Systems
20  */
21
22 #ifndef HWINFO_H
23 #define HWINFO_H
24
25 #include "simple.h"
26 #include "nbnxn_cuda_types_ext.h"
27 #include "../gmx_cpuid.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 #if 0
33 } /* fixes auto-indentation problems */
34 #endif
35
36 /* Possible results of the GPU detection/check.
37  *
38  * The egpuInsane value means that during the sanity checks an error
39  * occurred that indicates malfunctioning of the device, driver, or
40  * incompatible driver/runtime. */
41 typedef enum
42 {
43     egpuCompatible = 0,  egpuNonexistent,  egpuIncompatible, egpuInsane
44 } e_gpu_detect_res_t;
45
46 /* Textual names of the GPU detection/check results (see e_gpu_detect_res_t). */
47 static const char * const gpu_detect_res_str[] =
48 {
49     "compatible", "inexistent", "incompatible", "insane"
50 };
51
52 /* GPU device information -- for now with only CUDA devices.
53  * The gmx_hardware_detect module initializes it. */
54 typedef struct
55 {
56     gmx_bool             bDetectGPUs;          /* Did we try to detect GPUs? */
57     int                  ncuda_dev;            /* total number of devices detected */
58     cuda_dev_info_ptr_t  cuda_dev;             /* devices detected in the system (per node) */
59     int                  ncuda_dev_compatible; /* number of compatible GPUs */
60 } gmx_gpu_info_t;
61
62 /* Hardware information structure with CPU and GPU information.
63  * It is initialized by gmx_detect_hardware().
64  * NOTE: this structure may only contain structures that are globally valid
65  *       (i.e. must be able to be shared among all threads) */
66 typedef struct
67 {
68     gmx_gpu_info_t  gpu_info;            /* Information about GPUs detected in the system */
69
70     gmx_cpuid_t     cpuid_info;          /* CPUID information about CPU detected;
71                                             NOTE: this will only detect the CPU thread 0 of the
72                                             current process runs on. */
73     int             nthreads_hw_avail;   /* Number of hardware threads available; this number
74                                             is based on the number of CPUs reported as available
75                                             by the OS at the time of detection. */
76 } gmx_hw_info_t;
77
78
79 /* The options for the thread affinity setting, default: auto */
80 enum {
81     threadaffSEL, threadaffAUTO, threadaffON, threadaffOFF, threadaffNR
82 };
83
84 /* GPU device selection information -- for now with only CUDA devices */
85 typedef struct
86 {
87     char     *gpu_id;        /* GPU id's to use, each specified as chars */
88     gmx_bool  bUserSet;      /* true if the GPUs in cuda_dev_use are manually provided by the user */
89
90     int       ncuda_dev_use; /* number of device (IDs) selected to be used */
91     int      *cuda_dev_use;  /* device index list providing GPU to PP rank mapping, GPUs can be listed multiple times when ranks share them */
92 } gmx_gpu_opt_t;
93
94 /* Threading and GPU options, can be set automatically or by the user */
95 typedef struct {
96     int           nthreads_tot;        /* Total number of threads requested (TMPI) */
97     int           nthreads_tmpi;       /* Number of TMPI threads requested         */
98     int           nthreads_omp;        /* Number of OpenMP threads requested       */
99     int           nthreads_omp_pme;    /* As nthreads_omp, but for PME only nodes  */
100     int           thread_affinity;     /* Thread affinity switch, see enum above   */
101     int           core_pinning_stride; /* Logical core pinning stride              */
102     int           core_pinning_offset; /* Logical core pinning offset              */
103
104     gmx_gpu_opt_t gpu_opt;             /* The GPU options                          */
105 } gmx_hw_opt_t;
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif /* HWINFO_H */