MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / DeviceManager

Method DeviceManager

src/backend/oneapi/device_manager.cpp:87–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87DeviceManager::DeviceManager()
88 : logger(common::loggerFactory("platform"))
89 , mUserDeviceOffset(0)
90 , fgMngr(nullptr) {
91 vector<sycl::platform> platforms;
92 try {
93 platforms = sycl::platform::get_platforms();
94 } catch (sycl::exception& err) {
95 AF_ERROR(
96 "No sycl platforms found on this system. Ensure you have "
97 "installed the device driver as well as the runtime.",
98 AF_ERR_RUNTIME);
99 }
100
101 fgMngr = std::make_unique<ForgeManager>();
102
103 AF_TRACE("Found {} sycl platforms", platforms.size());
104 // Iterate through platforms, get all available devices and store them
105 for (auto& platform : platforms) {
106 vector<sycl::device> current_devices;
107 current_devices = platform.get_devices();
108 AF_TRACE("Found {} devices on platform {}", current_devices.size(),
109 platform.get_info<sycl::info::platform::name>());
110
111 for (auto& dev : current_devices) {
112 mDevices.emplace_back(make_unique<sycl::device>(dev));
113 AF_TRACE("Found device {} on platform {}",
114 dev.get_info<sycl::info::device::name>(),
115 platform.get_info<sycl::info::platform::name>());
116 }
117 }
118
119 int nDevices = mDevices.size();
120 AF_TRACE("Found {} sycl devices", nDevices);
121
122 if (nDevices == 0) { AF_ERROR("No sycl devices found", AF_ERR_RUNTIME); }
123
124 // Sort sycl devices based on default criteria
125 stable_sort(mDevices.begin(), mDevices.end(), compare_default);
126
127 auto devices = move(mDevices);
128 mDevices.clear();
129
130 // Create contexts and queues once the sort is done
131 for (int i = 0; i < nDevices; i++) {
132 if (devices[i]->is_gpu() || devices[i]->is_cpu()) {
133 try {
134 mContexts.push_back(make_unique<sycl::context>(*devices[i]));
135 mQueues.push_back(
136 make_unique<sycl::queue>(*mContexts.back(), *devices[i],
137 arrayfire_exception_handler));
138 mIsGLSharingOn.push_back(false);
139 // TODO:
140 // mDeviceTypes.push_back(getDeviceTypeEnum(*devices[i]));
141 // mPlatforms.push_back(getPlatformEnum(*devices[i]));
142 mDevices.emplace_back(std::move(devices[i]));
143
144 std::string options;

Callers

nothing calls this directly

Calls 6

loggerFactoryFunction · 0.85
getNameFunction · 0.85
getEnvVarFunction · 0.85
setActiveContextFunction · 0.70
getActiveDeviceIdFunction · 0.70
isLoadedMethod · 0.45

Tested by

no test coverage detected