From 119cedf0e62dc1025290ca6d27f363e87e7e48fc Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 6 Mar 2018 13:43:26 -0500
Subject: [PATCH] P4 to Git Change 1523412 by emankov@em-hsa on 2018/03/06
13:28:34
SWDEV-143465 - HSAIL - Compiler Lib - sync with legacy AMDIL libUtils
Sync with CL 1522654 (AMDIL)
[Reason] New Utility functions will be used in the upcomming changes in HSAIL path.
[Testing] p4precheckin (clean): http://ocltc.amd.com:8111/viewModification.html?modId=98811&personal=true&init=1&tab=vcsModificationBuilds
[Reviewd] by Stas: http://ocltc.amd.com/reviews/r/14345
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.h#31 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/target_mappings.h#54 edit
... //depot/stg/opencl/drivers/opencl/runtime/build/Makefile.runtime#73 edit
---
rocclr/compiler/lib/utils/v0_8/libUtils.cpp | 32 -------------
rocclr/compiler/lib/utils/v0_8/libUtils.h | 46 +++++++++++++++++++
.../compiler/lib/utils/v0_8/target_mappings.h | 4 +-
3 files changed, 48 insertions(+), 34 deletions(-)
diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
index d68f150edc..5cf95878aa 100644
--- a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
+++ b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
@@ -5,7 +5,6 @@
#include "api/v0_8/aclValidation.h"
#include "libUtils.h"
#include "bif/bifbase.hpp"
-#include "utils/target_mappings.h"
#include "utils/versions.hpp"
#include "utils/options.hpp"
#include
@@ -461,37 +460,6 @@ const char *getDeviceName(const aclTargetInfo &target)
return NULL;
}
-/*! Function that returns the TargetMapping for
- *the specific target device.
- */
-static const TargetMapping& getTargetMapping(const aclTargetInfo &target)
-{
- switch(target.arch_id) {
- default:
- assert(!"Passed a device id that is invalid!");
- break;
- case aclX64:
- return X64TargetMapping[target.chip_id];
- break;
- case aclX86:
- return X86TargetMapping[target.chip_id];
- break;
- case aclHSAIL:
- return HSAILTargetMapping[target.chip_id];
- break;
- case aclHSAIL64:
- return HSAIL64TargetMapping[target.chip_id];
- break;
- case aclAMDIL:
- return AMDILTargetMapping[target.chip_id];
- break;
- case aclAMDIL64:
- return AMDIL64TargetMapping[target.chip_id];
- break;
- };
- return UnknownTarget;
-}
-
/*! Function that returns the library type from the TargetMapping table for
*the specific target device id.
*/
diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h
index 3d288359ea..4c44d5bb5b 100644
--- a/rocclr/compiler/lib/utils/v0_8/libUtils.h
+++ b/rocclr/compiler/lib/utils/v0_8/libUtils.h
@@ -11,6 +11,7 @@
#include
#include
#include "library.hpp"
+#include "utils/target_mappings.h"
#include "utils/bif_section_labels.hpp"
#include "utils/options.hpp"
using namespace bif;
@@ -263,6 +264,34 @@ aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32
}
#endif
+// Returns the TargetMapping for the specific target device.
+inline const TargetMapping& getTargetMapping(const aclTargetInfo &target)
+{
+ switch (target.arch_id) {
+ default:
+ break;
+ case aclX64:
+ return X64TargetMapping[target.chip_id];
+ break;
+ case aclX86:
+ return X86TargetMapping[target.chip_id];
+ break;
+ case aclHSAIL:
+ return HSAILTargetMapping[target.chip_id];
+ break;
+ case aclHSAIL64:
+ return HSAIL64TargetMapping[target.chip_id];
+ break;
+ case aclAMDIL:
+ return AMDILTargetMapping[target.chip_id];
+ break;
+ case aclAMDIL64:
+ return AMDIL64TargetMapping[target.chip_id];
+ break;
+ };
+ return UnknownTarget;
+}
+
inline bool is64BitTarget(const aclTargetInfo& target)
{
return (target.arch_id == aclX64 ||
@@ -293,6 +322,23 @@ inline bool isHSAILTarget(const aclTargetInfo& target)
const std::string& getLegacyLibName();
+inline bool isValidTarget(const aclTargetInfo& target)
+{
+ return (target.arch_id && target.chip_id);
+}
+
+inline bool isChipSupported(const aclTargetInfo& target)
+{
+ if (!isValidTarget(target)) {
+ return false;
+ }
+ const TargetMapping& Mapping = getTargetMapping(target);
+ if (Mapping.family_enum == FAMILY_UNKNOWN) {
+ return false;
+ }
+ return Mapping.supported;
+}
+
enum scId {
SC_AMDIL = 0,
SC_HSAIL = 0,
diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings.h b/rocclr/compiler/lib/utils/v0_8/target_mappings.h
index 3cb3ade577..e6a30d977c 100644
--- a/rocclr/compiler/lib/utils/v0_8/target_mappings.h
+++ b/rocclr/compiler/lib/utils/v0_8/target_mappings.h
@@ -34,9 +34,9 @@ typedef struct _target_mappings_rec {
} TargetMapping;
const TargetMapping UnknownTarget = { "UnknownFamily", "UnknownChip", "UnknownCodeGen",
- amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN};
+ amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false};
const TargetMapping InvalidTarget = { NULL, NULL, NULL,
- amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN};
+ amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false};
typedef struct _family_map_rec {
const TargetMapping* target;