66 */
77
88#pragma once
9+ #include " common/helpers/bit_helpers.h"
910#include " runtime/command_stream/preemption_mode.h"
1011#include " runtime/utilities/reference_tracked_object.h"
1112
1213#include " engine_node.h"
1314
15+ #include < limits>
1416#include < memory>
1517
1618namespace OCLRT {
@@ -20,19 +22,28 @@ class OsContext : public ReferenceTrackedObject<OsContext> {
2022 public:
2123 OsContext () = delete ;
2224
23- static OsContext *create (OSInterface *osInterface, uint32_t contextId, uint32_t numDevicesSupported , EngineInstanceT engineType, PreemptionMode preemptionMode);
25+ static OsContext *create (OSInterface *osInterface, uint32_t contextId, uint32_t deviceBitfiled , EngineInstanceT engineType, PreemptionMode preemptionMode);
2426 uint32_t getContextId () const { return contextId; }
25- uint32_t getNumDevicesSupported () const { return numDevicesSupported; }
27+ uint32_t getNumSupportedDevices () const { return numSupportedDevices; }
28+ uint8_t getDeviceBitfiled () const { return deviceBitfiled; }
2629 PreemptionMode getPreemptionMode () const { return preemptionMode; }
2730 EngineInstanceT &getEngineType () { return engineType; }
2831
2932 protected:
30- OsContext (uint32_t contextId, uint32_t numDevicesSupported, EngineInstanceT engineType, PreemptionMode preemptionMode)
31- : contextId(contextId), numDevicesSupported(numDevicesSupported), preemptionMode(preemptionMode), engineType(engineType){};
33+ OsContext (uint32_t contextId, uint32_t deviceBitfiled, EngineInstanceT engineType, PreemptionMode preemptionMode)
34+ : contextId(contextId), deviceBitfiled(deviceBitfiled), preemptionMode(preemptionMode), engineType(engineType) {
35+ constexpr uint32_t maxIndex = std::numeric_limits<decltype (deviceBitfiled)>::digits;
36+ for (uint32_t deviceIndex = 0 ; deviceIndex < maxIndex; deviceIndex++) {
37+ if (isBitSet (deviceBitfiled, deviceIndex)) {
38+ numSupportedDevices++;
39+ }
40+ }
41+ };
3242
3343 const uint32_t contextId;
34- const uint32_t numDevicesSupported ;
44+ const uint32_t deviceBitfiled ;
3545 const PreemptionMode preemptionMode;
46+ uint32_t numSupportedDevices = 0 ;
3647 EngineInstanceT engineType = {EngineType::ENGINE_RCS, 0 };
3748};
3849} // namespace OCLRT
0 commit comments