! * \brief abstraction of a streaming computing resource on localhost (a * thread on CPU, a cuda stream, etc.) * * Note that most of the operations are asynchronous with respect to the caller * thread */
| 51 | * thread |
| 52 | */ |
| 53 | class CompNode { |
| 54 | public: |
| 55 | //! computing device type |
| 56 | enum class DeviceType { |
| 57 | //! for "xpu" comp node that would mapped to available cn on |
| 58 | //! current system |
| 59 | UNSPEC = 0, |
| 60 | |
| 61 | CUDA = 1, |
| 62 | CPU = 2, |
| 63 | CAMBRICON = 3, |
| 64 | ROCM = 8, |
| 65 | ATLAS = 9, |
| 66 | MULTITHREAD = 11, |
| 67 | MAX_DEVICE_ID, |
| 68 | }; |
| 69 | static constexpr size_t NR_DEVICE_TYPE = |
| 70 | static_cast<size_t>(DeviceType::MAX_DEVICE_ID); |
| 71 | |
| 72 | struct DeviceProperties { |
| 73 | DeviceProperties() { |
| 74 | name = "unspec"; |
| 75 | total_memory = major = minor = 0; |
| 76 | } |
| 77 | |
| 78 | std::string name; |
| 79 | size_t total_memory; |
| 80 | |
| 81 | //! for cuda |
| 82 | int major; |
| 83 | int minor; |
| 84 | }; |
| 85 | |
| 86 | /*! |
| 87 | * \brief an identifier to specify a computing node |
| 88 | * |
| 89 | * Note: logical locator is directly parsed from a string identifier |
| 90 | * given by user; it should be translated to physical locator by calling |
| 91 | * to_physical() before actual use. |
| 92 | * |
| 93 | * Unless explicitly specified otherwise, all locators are physical |
| 94 | * locators. |
| 95 | */ |
| 96 | struct Locator { |
| 97 | /*! |
| 98 | * \brief special device number for the "cpu default" comp node, |
| 99 | * which dispatches all tasks in the caller thread |
| 100 | */ |
| 101 | static constexpr int DEVICE_CPU_DEFAULT = -1024; |
| 102 | /*! |
| 103 | * \brief special device number for the "multithread_default" |
| 104 | * comp node, which dispatches all tasks to thread pool and the |
| 105 | * caller thread is the main thread of thread pool |
| 106 | */ |
| 107 | static constexpr int DEVICE_MULTITHREAD_DEFAULT = -1025; |
| 108 | |
| 109 | DeviceType type = DeviceType::UNSPEC; |
| 110 |
no outgoing calls