kfdtest: Add Assembler::RunAssembleBuf overload
Overload Assembler::RunAssembleBuf to take in an extra Gfxv parameter.
Using this overload will temporarily set the target ASIC to Gfxv before
calling RunAssemble, and copy back the original MCPU literal upon
completion. The copy to reset the original MCPU in this case is safe as
the MCPU length is always known.
This will be useful in multi-device test cases whereby the devices are
not necessarily the same gfx version. The overload is explicitly for the
RunAssembleBuf wrapper rather than RunAssemble to ensure the default
MCPU is always reset independent of errors in RunAssemble.
Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Change-Id: I7fe5a962876314b6df32e4b7160174949d98f9e3
[ROCm/ROCR-Runtime commit: 54136f60a0]
This commit is contained in:
@@ -224,6 +224,7 @@ int Assembler::ExtractELFText(const char* RawData) {
|
||||
* @param AssemblySource Shader source represented as a raw C string
|
||||
* @param OutBuf Raw instruction stream output buffer
|
||||
* @param BufSize Size of OutBuf (defaults to PAGE_SIZE)
|
||||
* @param Gfxv Optional overload to temporarily set target ASIC
|
||||
* @return Value of RunAssemble() (0 on success)
|
||||
*/
|
||||
int Assembler::RunAssembleBuf(const char* const AssemblySource, char* OutBuf,
|
||||
@@ -231,6 +232,14 @@ int Assembler::RunAssembleBuf(const char* const AssemblySource, char* OutBuf,
|
||||
int ret = RunAssemble(AssemblySource);
|
||||
return ret ? ret : CopyInstrStream(OutBuf, BufSize);
|
||||
}
|
||||
int Assembler::RunAssembleBuf(const char* const AssemblySource, char* OutBuf,
|
||||
const size_t BufSize, const uint32_t Gfxv) {
|
||||
const char* defaultMCPU = GetTargetAsic();
|
||||
SetTargetAsic(Gfxv);
|
||||
int ret = RunAssemble(AssemblySource);
|
||||
strncpy(MCPU, defaultMCPU, ASM_MCPU_LEN);
|
||||
return ret ? ret : CopyInstrStream(OutBuf, BufSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assemble shader and fill member vars
|
||||
|
||||
@@ -81,6 +81,8 @@ class Assembler {
|
||||
int RunAssemble(const char* const AssemblySource);
|
||||
int RunAssembleBuf(const char* const AssemblySource, char* OutBuf,
|
||||
const size_t BufSize = PAGE_SIZE);
|
||||
int RunAssembleBuf(const char* const AssemblySource, char* OutBuf,
|
||||
const size_t BufSize, const uint32_t Gfxv);
|
||||
};
|
||||
|
||||
#endif // _ASSEMBLE_H_
|
||||
|
||||
Reference in New Issue
Block a user