P4 to Git Change 1108714 by rayxiao@alit_opencl_rayxiao on 2015/01/05 09:58:36

EPR #399415 - Move aclInsertKernelStatistics to utility library. aclutInsertKernelStatistics.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.def.in#11 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.map.in#12 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.def.in#9 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.map.in#8 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclKstatsSI.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclKstatsr800.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/devState.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/devState.h#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/acl.h#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclEnums.h#15 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclStructs.h#14 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/bif/bifinternal.hpp#8 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/bif_section_labels.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.h#14 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuscsi.cpp#27 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/CLEnumCheck.cpp#39 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/aclAPI.cpp#18 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/aclAPI.hpp#3 edit
This commit is contained in:
foreman
2015-01-05 10:06:36 -05:00
parent 01cfbfc12c
commit ddff965589
9 changed files with 87 additions and 8 deletions
+1
View File
@@ -37,6 +37,7 @@ aclSetType
aclConvertType
aclDisassemble
aclGetDeviceBinary
aclInsertKernelStatistics
oclCompilerInit
oclCompilerFini
oclCompilerVersion
+1
View File
@@ -82,6 +82,7 @@ global:
aclSetType;
aclConvertType;
aclDisassemble;
aclInsertKernelStatistics;
aclGetDeviceBinary;
aclLoader_OnLoad;
aclLoader_OnUnload;
+12 -2
View File
@@ -7,7 +7,6 @@
extern "C" {
#endif
#include "aclTypes.h"
//!--------------------------------------------------------------------------!//
// Functions that deal with aclCompiler objects.
//!--------------------------------------------------------------------------!//
@@ -235,7 +234,18 @@ const void* ACL_API_ENTRY
// Debug functionality
//!--------------------------------------------------------------------------!//
void aclDumpBinary(const aclBinary *bin);
// Functions to retrieve kernel information
void aclGetKstatsR800(const void* shader,
aclKernelStats &kstats, const char* chip_id);
void aclGetKstatsSI(const void* shader,
aclKernelStats &kstats);
acl_error
aclInsertKernelStatistics(aclCompiler *cl,
aclBinary *bin);
//! Define hardware info constants for SI and above devices
const static unsigned SI_sgprs_avail = 102;
const static unsigned SI_vgprs_avail = 256;
const static unsigned SI_ldssize_avail = 32*1024;
//!--------------------------------------------------------------------------!//
// Functions that deal with memory.
+2 -1
View File
@@ -182,7 +182,8 @@ typedef enum _bif_sections_enum_0_8 {
aclBRIGoprs = 32,
aclBRIGstrs = 33,
aclHSADEBUG = 34,
aclLAST = 35
aclKSTATS = 35, // For storing kernel statistics
aclLAST = 36
} aclSections_0_8;
//! An enumeration that defines what are valid queries for aclQueryInfo.
@@ -311,4 +311,24 @@ typedef struct _acl_compiler_rec_0_8_1 {
aclLoaderData *apiData; // pointer to data store for the compiler API loader.
} aclCompilerHandle_0_8_1;
//! Structure to hold kernel statistics obtained from kernel
typedef struct _acl_kernel_stats_0_8_1 {
unsigned int scratchRegs;
unsigned int scratchSize;
unsigned int availablevgprs;
unsigned int availablesgprs;
unsigned int usedvgprs;
unsigned int usedsgprs;
unsigned int availableldssize;
unsigned int usedldssize;
unsigned int availablestacksize;
unsigned int usedstacksize;
unsigned int wavefrontsize;
unsigned int wavefrontpersimd;
unsigned int threadsperworkgroup;
unsigned int reqdworkgroup_x;
unsigned int reqdworkgroup_y;
unsigned int reqdworkgroup_z;
} aclKernelStats;
#endif // _ACL_STRUCTS_0_8_H_
@@ -36,7 +36,8 @@ typedef enum {
symDebugilBinary,
symAsmText,
symDLL,
symLast
symLast,
symKernelStats
} oclBIFSymbolID;
struct oclBIFSymbolStruct {
@@ -48,7 +49,7 @@ struct oclBIFSymbolStruct {
};
// These are the symbols that are defined by the BIF 3.0 spec
static const oclBIFSymbolStruct BIF30[26] =
static const oclBIFSymbolStruct BIF30[27] =
{
// 0: BIF 3.0 compiler options, .comment section via library support.
{symOpenclCompilerOptions,
@@ -106,6 +107,8 @@ static const oclBIFSymbolStruct BIF30[26] =
{symDebugilBinary, { "__debugil_binary", "" }, {aclINTERNAL, aclLAST}},
{symAsmText, {"", ""}, {aclLAST, aclCODEGEN}},
{symDLL, {"", ""}, {aclLAST, aclTEXT}},
// 26: BIF 3.0 HSAIL kernel statistics
{symKernelStats, { "__HSAIL_", "_kernel_statistics" }, {aclKSTATS, aclLAST}},
}; // BIF30
@@ -3,6 +3,7 @@
//
#include "acl.h"
#include "aclTypes.h"
#include "api/v0_8/aclValidation.h"
#include "v0_7/clTypes.h"
#include "v0_7/clCompiler.h"
#include "libUtils.h"
@@ -10,6 +11,7 @@
#include "utils/target_mappings.h"
#include "utils/versions.hpp"
#include "utils/options.hpp"
#include "backends/gpu/scwrapper/devState.h"
#include <cassert>
#include <cstring>
#include "bif/bif.hpp"
@@ -373,6 +375,43 @@ aclutCopyBinOpts(aclBinaryOptions *dst, const aclBinaryOptions *src, bool is64)
}
}
acl_error
aclutInsertKernelStatistics(aclCompiler *cl, aclBinary *bin)
{
if (!aclValidateCompiler(cl, true)) {
return ACL_INVALID_COMPILER;
}
if (!aclValidateBinary(bin)) {
return ACL_INVALID_BINARY;
}
size_t len = 0;
acl_error err = ACL_SUCCESS;
const void *isa = aclExtractSection(cl, bin, &len, aclTEXT, &err);
if (err != ACL_SUCCESS)
return err;
aclTargetInfo *tgtInfo = aclutGetTargetInfo(bin);
const char* chipName = aclGetChip(*tgtInfo);
unsigned family = getFamilyEnum(tgtInfo);
unsigned chip = getChipEnum(tgtInfo);
// Non-GPU devices have family_enum set to 1 and do not qualify. Need to update.
if (family >= FAMILY_R600 &&
family <= FAMILY_CZ) {
aclKernelStats kstats = {0};
if (family < FAMILY_SI) {
aclGetKstatsR800(isa, kstats, chipName);
}
else {
aclGetKstatsSI(isa, kstats);
}
kstats.wavefrontsize = amdcl::GetWavefrontSize(family, chip);
const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symKernelStats);
assert(symbol && "symbol not found");
std::string symName = std::string(symbol->str[PRE]) + std::string(symbol->str[POST]);
err = aclInsertSymbol(cl, bin, reinterpret_cast<void*>(&kstats), sizeof(kstats), aclKSTATS, symName.c_str());
}
return err;
}
void initElfDeviceCaps(aclBinary *elf)
{
if (aclutGetCaps(elf)->encryptCode) {
@@ -108,6 +108,10 @@ aclutCopyBinOpts(aclBinaryOptions *dst,
const aclBinaryOptions *src,
bool is64bit);
// Retrieve kernel statistics from binary
// and insert to elf as symbol
acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*);
// Helper function that returns the
// allocation function from the binary.
AllocFunc
+3 -3
View File
@@ -56,10 +56,10 @@ NullKernel::siCreateHwInfo(const void* shader, AMUabiAddEncoding& encoding)
newInfos[i].value = cShader->common.numSgprs;
i++;
newInfos[i].address = AMU_ABI_SI_NUM_SGPRS_AVAIL;
newInfos[i].value = 104-2; //512;//options.NumSGPRsAvailable;
newInfos[i].value = SI_sgprs_avail; //512;//options.NumSGPRsAvailable;
i++;
newInfos[i].address = AMU_ABI_SI_NUM_VGPRS_AVAIL;
newInfos[i].value = 256;//options.NumVGPRsAvailable;
newInfos[i].value = SI_vgprs_avail;//options.NumVGPRsAvailable;
i++;
newInfos[i].address = AMU_ABI_SI_FLOAT_MODE;
@@ -110,7 +110,7 @@ NullKernel::siCreateHwInfo(const void* shader, AMUabiAddEncoding& encoding)
i++;
newInfos[i].address = AMU_ABI_LDS_SIZE_AVAIL;
newInfos[i].value = 32*1024; //options.LDSSize;
newInfos[i].value = SI_ldssize_avail; //options.LDSSize;
i++;
COMPUTE_PGM_RSRC2 computePgmRsrc2;