|
26 | 26 | #include "dpctl_utils_helper.h" |
27 | 27 | #include "Config/dpctl_config.h" |
28 | 28 | #include <sstream> |
| 29 | +#include <stdexcept> |
29 | 30 | #include <string> |
30 | 31 |
|
31 | 32 | using namespace sycl; |
@@ -466,7 +467,101 @@ DPCTLPartitionAffinityDomainType DPCTL_SyclPartitionAffinityDomainToDPCTLType( |
466 | 467 | case info::partition_affinity_domain::next_partitionable: |
467 | 468 | return DPCTLPartitionAffinityDomainType::next_partitionable; |
468 | 469 | default: |
469 | | - throw std::runtime_error("Unsupported partition_affinity_domain type"); |
| 470 | + return DPCTLPartitionAffinityDomainType:: |
| 471 | + DPCTL_PARTITION_AFFINITY_DOMAIN_UNKNOWN; |
| 472 | + } |
| 473 | +} |
| 474 | + |
| 475 | +DPCTLFPConfigType DPCTL_SyclFPConfigToDPCTLType(info::fp_config FPConfig) |
| 476 | +{ |
| 477 | + switch (FPConfig) { |
| 478 | + case info::fp_config::denorm: |
| 479 | + return DPCTLFPConfigType::DPCTL_FP_DENORM; |
| 480 | + case info::fp_config::inf_nan: |
| 481 | + return DPCTLFPConfigType::DPCTL_FP_INF_NAN; |
| 482 | + case info::fp_config::round_to_nearest: |
| 483 | + return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_NEAREST; |
| 484 | + case info::fp_config::round_to_zero: |
| 485 | + return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_ZERO; |
| 486 | + case info::fp_config::round_to_inf: |
| 487 | + return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_INF; |
| 488 | + case info::fp_config::fma: |
| 489 | + return DPCTLFPConfigType::DPCTL_FP_FMA; |
| 490 | + case info::fp_config::correctly_rounded_divide_sqrt: |
| 491 | + return DPCTLFPConfigType::DPCTL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT; |
| 492 | + case info::fp_config::soft_float: |
| 493 | + return DPCTLFPConfigType::DPCTL_FP_SOFT_FLOAT; |
| 494 | + default: |
| 495 | + return DPCTLFPConfigType::DPCTL_FP_UNKNOWN; |
| 496 | + } |
| 497 | +} |
| 498 | + |
| 499 | +DPCTLLocalMemType |
| 500 | +DPCTL_SyclLocalMemTypeToDPCTLType(info::local_mem_type LocalMemType) |
| 501 | +{ |
| 502 | + switch (LocalMemType) { |
| 503 | + case info::local_mem_type::none: |
| 504 | + return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_NONE; |
| 505 | + case info::local_mem_type::local: |
| 506 | + return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_LOCAL; |
| 507 | + case info::local_mem_type::global: |
| 508 | + return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_GLOBAL; |
| 509 | + default: |
| 510 | + return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_UNKNOWN; |
| 511 | + } |
| 512 | +} |
| 513 | + |
| 514 | +DPCTLMemoryOrderType DPCTL_SyclMemoryOrderToDPCTLType(memory_order MemoryOrder) |
| 515 | +{ |
| 516 | + switch (MemoryOrder) { |
| 517 | + case memory_order::relaxed: |
| 518 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_RELAXED; |
| 519 | + case memory_order::acquire: |
| 520 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_ACQUIRE; |
| 521 | + case memory_order::release: |
| 522 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_RELEASE; |
| 523 | + case memory_order::acq_rel: |
| 524 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_ACQ_REL; |
| 525 | + case memory_order::seq_cst: |
| 526 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_SEQ_CST; |
| 527 | + default: |
| 528 | + return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_UNKNOWN; |
| 529 | + } |
| 530 | +} |
| 531 | + |
| 532 | +DPCTLMemoryScopeType DPCTL_SyclMemoryScopeToDPCTLType(memory_scope MemoryScope) |
| 533 | +{ |
| 534 | + switch (MemoryScope) { |
| 535 | + case memory_scope::work_item: |
| 536 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_WORK_ITEM; |
| 537 | + case memory_scope::sub_group: |
| 538 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_SUB_GROUP; |
| 539 | + case memory_scope::work_group: |
| 540 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_WORK_GROUP; |
| 541 | + case memory_scope::device: |
| 542 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_DEVICE; |
| 543 | + case memory_scope::system: |
| 544 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_SYSTEM; |
| 545 | + default: |
| 546 | + return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_UNKNOWN; |
| 547 | + } |
| 548 | +} |
| 549 | + |
| 550 | +DPCTLPartitionPropertyType DPCTL_SyclPartitionPropertyToDPCTLType( |
| 551 | + info::partition_property PartitionProperty) |
| 552 | +{ |
| 553 | + switch (PartitionProperty) { |
| 554 | + case info::partition_property::no_partition: |
| 555 | + return DPCTLPartitionPropertyType::DPCTL_PARTITION_NO_PARTITION; |
| 556 | + case info::partition_property::partition_equally: |
| 557 | + return DPCTLPartitionPropertyType::DPCTL_PARTITION_EQUALLY; |
| 558 | + case info::partition_property::partition_by_counts: |
| 559 | + return DPCTLPartitionPropertyType::DPCTL_PARTITION_BY_COUNTS; |
| 560 | + case info::partition_property::partition_by_affinity_domain: |
| 561 | + return DPCTLPartitionPropertyType::DPCTL_PARTITION_BY_AFFINITY_DOMAIN; |
| 562 | + default: |
| 563 | + // TODO: investigate ext_intel_partition_by_cslice extension |
| 564 | + return DPCTLPartitionPropertyType::DPCTL_PARTITION_UNKNOWN; |
470 | 565 | } |
471 | 566 | } |
472 | 567 |
|
|
0 commit comments