================================================================================================
| 269 | |
| 270 | // ================================================================================================ |
| 271 | hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { |
| 272 | unsigned supportedFlags = hipEventDefault | hipEventBlockingSync | hipEventDisableTiming | |
| 273 | hipEventReleaseToDevice | hipEventReleaseToSystem | |
| 274 | hipEventInterprocess | hipEventDisableSystemFence; |
| 275 | |
| 276 | const unsigned releaseFlags = |
| 277 | (hipEventReleaseToDevice | hipEventReleaseToSystem | hipEventDisableSystemFence); |
| 278 | // can't set any unsupported flags. |
| 279 | // can set only one of the release flags. |
| 280 | // if hipEventInterprocess flag is set, then hipEventDisableTiming flag also must be set |
| 281 | const bool illegalFlags = (flags & ~supportedFlags) || ([](unsigned int num) { |
| 282 | unsigned int bitcount; |
| 283 | for (bitcount = 0; num; bitcount++) { |
| 284 | num &= num - 1; |
| 285 | } |
| 286 | return bitcount; |
| 287 | }(flags & releaseFlags) > 1) || |
| 288 | ((flags & hipEventInterprocess) && !(flags & hipEventDisableTiming)); |
| 289 | if (!illegalFlags) { |
| 290 | hip::Event* e = nullptr; |
| 291 | if (flags & hipEventInterprocess) { |
| 292 | e = new hip::IPCEvent(); |
| 293 | } else { |
| 294 | if (AMD_DIRECT_DISPATCH) { |
| 295 | e = new hip::EventDD(flags); |
| 296 | } else { |
| 297 | e = new hip::Event(flags); |
| 298 | } |
| 299 | } |
| 300 | // App might have used combination of flags i.e. hipEventInterprocess|hipEventDisableTiming |
| 301 | // However based on hipEventInterprocess flag, IPCEvent creates even with |
| 302 | // JUST hipEventInterprocess and hence, Actual hipEventInterprocess|hipEventDisableTiming |
| 303 | // flag is getting supressed with hipEventInterprocess |
| 304 | e->flags_ = flags; |
| 305 | if (e == nullptr) { |
| 306 | return hipErrorOutOfMemory; |
| 307 | } |
| 308 | *event = reinterpret_cast<hipEvent_t>(e); |
| 309 | std::unique_lock lock(hip::eventSetLock); |
| 310 | hip::eventSet.insert(*event); |
| 311 | } else { |
| 312 | return hipErrorInvalidValue; |
| 313 | } |
| 314 | return hipSuccess; |
| 315 | } |
| 316 | |
| 317 | // ================================================================================================ |
| 318 | hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { |
no outgoing calls
no test coverage detected