Skip to content

Commit 26e95a5

Browse files
zuban32sys_zuul
authored andcommitted
Fixed GetVISAKernel to return kernel by name (if provided).
This resolves a problem with several kernels/functions in a module - prevoiusly the function it returned the last added one. Change-Id: I9f54f567e42f6fda01585140cf706aea3b99a488
1 parent 226e173 commit 26e95a5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

visa/BuildCISAIR.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CISA_IR_Builder : public VISABuilder
9393
VISA_BUILDER_API virtual int WriteVISAHeader();
9494
VISA_BUILDER_API std::stringstream& GetAsmTextStream() { return m_ssIsaAsm; }
9595
VISA_BUILDER_API std::stringstream& GetAsmTextHeaderStream() { return m_ssIsaAsmHeader; }
96-
VISA_BUILDER_API virtual VISAKernel* GetVISAKernel();
96+
VISA_BUILDER_API virtual VISAKernel* GetVISAKernel(const std::string& kernelName);
9797
VISA_BUILDER_API virtual int ClearAsmTextStreams();
9898

9999
/**************END VISA BUILDER API*************************/
@@ -726,6 +726,10 @@ class CISA_IR_Builder : public VISABuilder
726726
std::list<VISAKernelImpl *> m_kernels;
727727
//keeps track of functions for stitching purposes, after compilation.
728728
std::vector<VISAFunction *> m_functionsVector;
729+
// for cases of several kernels/functions in one CisaBuilder
730+
// we need to keep a mapping of kernels to names
731+
// to make GetVISAKernel() work
732+
std::map<std::string, VISAKernelImpl *> m_nameToKernel;
729733

730734
void emitFCPatchFile();
731735

visa/BuildCISAIRImpl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,11 @@ bool CISA_IR_Builder::CISA_IR_initialization(char *kernel_name,
340340
return true;
341341
}
342342

343-
VISAKernel* CISA_IR_Builder::GetVISAKernel()
343+
VISAKernel* CISA_IR_Builder::GetVISAKernel(const std::string& kernelName)
344344
{
345-
return static_cast<VISAKernel*>(m_kernel);
345+
if (kernelName.empty())
346+
return static_cast<VISAKernel*>(m_kernel);
347+
return static_cast<VISAKernel*>(m_nameToKernel.at(kernelName));
346348
}
347349

348350
int CISA_IR_Builder::ClearAsmTextStreams()
@@ -380,6 +382,7 @@ int CISA_IR_Builder::AddKernel(VISAKernel *& kernel, const char* kernelName)
380382
m_kernel->InitializeKernel(kernelName);
381383
m_kernel->SetGTPinInit(getGtpinInit());
382384
this->m_kernel_count++;
385+
this->m_nameToKernel[kernelName] = m_kernel;
383386

384387
if (m_options.getOption(vISA_IsaAssembly))
385388
{

visa/include/VISABuilderAPIDefinition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ class VISABuilder
827827
VISA_BUILDER_API virtual int WriteVISAHeader() = 0;
828828
VISA_BUILDER_API virtual std::stringstream& GetAsmTextStream() = 0;
829829
VISA_BUILDER_API virtual std::stringstream& GetAsmTextHeaderStream() = 0;
830-
VISA_BUILDER_API virtual VISAKernel* GetVISAKernel() = 0;
830+
VISA_BUILDER_API virtual VISAKernel* GetVISAKernel(const std::string& kernelName = "") = 0;
831831
VISA_BUILDER_API virtual int ClearAsmTextStreams() = 0;
832832
VISA_BUILDER_API virtual std::string GetCriticalMsg() = 0;
833833
};

0 commit comments

Comments
 (0)