|
12 | 12 | #include "utils/utils_string.hpp" |
13 | 13 | #include "logging/logging.hpp" |
14 | 14 |
|
| 15 | +namespace { |
| 16 | +std::stringstream &to_string_helper(std::stringstream &ss) { |
| 17 | + if (ss.str().empty()) { |
| 18 | + ss << "|NONE|"; |
| 19 | + } |
| 20 | + return ss; |
| 21 | +} |
| 22 | +} // namespace |
15 | 23 | namespace level_zero_tests { |
16 | 24 |
|
17 | 25 | std::string to_string(const ze_api_version_t version) { |
@@ -415,15 +423,15 @@ std::string to_string(const ze_image_format_swizzle_t swizzle) { |
415 | 423 | } |
416 | 424 |
|
417 | 425 | std::string to_string(const ze_image_flag_t flag) { |
418 | | - std::string flags = ""; |
| 426 | + std::stringstream flags; |
419 | 427 | if (flag & ZE_IMAGE_FLAG_KERNEL_WRITE) { |
420 | | - flags.append("|ZE_IMAGE_FLAG_KERNEL_WRITE|"); |
| 428 | + flags << "|ZE_IMAGE_FLAG_KERNEL_WRITE|"; |
421 | 429 | } |
422 | 430 | if (flag & ZE_IMAGE_FLAG_BIAS_UNCACHED) { |
423 | | - flags.append("|ZE_IMAGE_FLAG_BIAS_UNCACHED|"); |
| 431 | + flags << "|ZE_IMAGE_FLAG_BIAS_UNCACHED|"; |
424 | 432 | } |
425 | 433 |
|
426 | | - return flags; |
| 434 | + return to_string_helper(flags).str(); |
427 | 435 | } |
428 | 436 |
|
429 | 437 | ze_image_flags_t to_image_flag(const std::string flag) { |
@@ -476,37 +484,73 @@ ze_image_type_t to_image_type(const std::string type) { |
476 | 484 | } |
477 | 485 | } |
478 | 486 |
|
479 | | -std::string to_string(const ze_device_fp_flags_t capabilities) { |
480 | | - std::string capabilities_str = ""; |
481 | | - if (capabilities == 0) { |
482 | | - capabilities_str.append("|NONE|"); |
483 | | - return capabilities_str; |
| 487 | +std::string to_string(const ze_device_fp_flag_t flags) { |
| 488 | + std::stringstream bitfield; |
| 489 | + if (flags & ZE_DEVICE_FP_FLAG_DENORM) { |
| 490 | + bitfield << "|ZE_DEVICE_FP_FLAG_DENORM|"; |
| 491 | + } |
| 492 | + if (flags & ZE_DEVICE_FP_FLAG_INF_NAN) { |
| 493 | + bitfield << "|ZE_DEVICE_FP_FLAG_INF_NAN|"; |
| 494 | + } |
| 495 | + if (flags & ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST) { |
| 496 | + bitfield << "|ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST|"; |
484 | 497 | } |
485 | | - if (capabilities & ZE_DEVICE_FP_FLAG_DENORM) { |
486 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_DENORM|"); |
| 498 | + if (flags & ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO) { |
| 499 | + bitfield << "|ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO|"; |
487 | 500 | } |
488 | | - if (capabilities & ZE_DEVICE_FP_FLAG_INF_NAN) { |
489 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_INF_NAN|"); |
| 501 | + if (flags & ZE_DEVICE_FP_FLAG_ROUND_TO_INF) { |
| 502 | + bitfield << "|ZE_DEVICE_FP_FLAG_ROUND_TO_INF|"; |
490 | 503 | } |
491 | | - if (capabilities & ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST) { |
492 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST|"); |
| 504 | + if (flags & ZE_DEVICE_FP_FLAG_FMA) { |
| 505 | + bitfield << "|ZE_DEVICE_FP_FLAG_FMA|"; |
493 | 506 | } |
494 | | - if (capabilities & ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO) { |
495 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO|"); |
| 507 | + if (flags & ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT) { |
| 508 | + bitfield << "|ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT|"; |
| 509 | + } |
| 510 | + if (flags & ZE_DEVICE_FP_FLAG_SOFT_FLOAT) { |
| 511 | + bitfield << "|ZE_DEVICE_FP_FLAG_SOFT_FLOAT|"; |
| 512 | + } |
| 513 | + return to_string_helper(bitfield).str(); |
| 514 | +} |
| 515 | + |
| 516 | +std::string to_string(const ze_memory_access_cap_flag_t flags) { |
| 517 | + std::stringstream bitfield; |
| 518 | + if (flags & ZE_MEMORY_ACCESS_CAP_FLAG_RW) { |
| 519 | + bitfield << "|ZE_MEMORY_ACCESS_CAP_FLAG_RW|"; |
| 520 | + } |
| 521 | + if (flags & ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC) { |
| 522 | + bitfield << "|ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC|"; |
| 523 | + } |
| 524 | + if (flags & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT) { |
| 525 | + bitfield << "|ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT|"; |
| 526 | + } |
| 527 | + if (flags & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC) { |
| 528 | + bitfield << "|ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC|"; |
| 529 | + } |
| 530 | + if (flags & ZE_MEMORY_ACCESS_CAP_FLAG_FORCE_UINT32) { |
| 531 | + bitfield << "|ZE_MEMORY_ACCESS_CAP_FLAG_FORCE_UINT32|"; |
| 532 | + } |
| 533 | + return to_string_helper(bitfield).str(); |
| 534 | +} |
| 535 | + |
| 536 | +std::string to_string(const ze_device_property_flag_t flags) { |
| 537 | + std::stringstream bitfield; |
| 538 | + if (flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) { |
| 539 | + bitfield << "|ZE_DEVICE_PROPERTY_FLAG_INTEGRATED|"; |
496 | 540 | } |
497 | | - if (capabilities & ZE_DEVICE_FP_FLAG_ROUND_TO_INF) { |
498 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_ROUND_TO_INF|"); |
| 541 | + if (flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE) { |
| 542 | + bitfield << "|ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE|"; |
499 | 543 | } |
500 | | - if (capabilities & ZE_DEVICE_FP_FLAG_FMA) { |
501 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_FMA|"); |
| 544 | + if (flags & ZE_DEVICE_PROPERTY_FLAG_ECC) { |
| 545 | + bitfield << "|ZE_DEVICE_PROPERTY_FLAG_ECC|"; |
502 | 546 | } |
503 | | - if (capabilities & ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT) { |
504 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT|"); |
| 547 | + if (flags & ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING) { |
| 548 | + bitfield << "|ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING|"; |
505 | 549 | } |
506 | | - if (capabilities & ZE_DEVICE_FP_FLAG_SOFT_FLOAT) { |
507 | | - capabilities_str.append("|ZE_DEVICE_FP_FLAG_SOFT_FLOAT|"); |
| 550 | + if (flags & ZE_DEVICE_PROPERTY_FLAG_FORCE_UINT32) { |
| 551 | + bitfield << "|ZE_DEVICE_PROPERTY_FLAG_FORCE_UINT32|"; |
508 | 552 | } |
509 | | - return capabilities_str; |
| 553 | + return to_string_helper(bitfield).str(); |
510 | 554 | } |
511 | 555 |
|
512 | 556 | static char hexdigit(int i) { return (i > 9) ? 'a' - 10 + i : '0' + i; } |
|
0 commit comments