Skip to content

Commit 502dea5

Browse files
ViacheslavRbigcbot
authored andcommitted
Fixing alignment of input in visa code
Fixing alignment of inputs in visa code for pointers arguments.
1 parent 16b7673 commit 502dea5

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,9 @@ namespace IGC
24752475
// Align on the desired alignment for this argument
24762476
auto alignment = arg.getAlignment();
24772477

2478+
if (arg.isArgPtrType())
2479+
alignment = m_Context->getModule()->getDataLayout().getPointerTypeSize(arg.getArg()->getType());
2480+
24782481
// FIXME: move alignment checks to implicit arg creation
24792482
if ((arg.getArgType() == KernelArg::ArgType::IMPLICIT_LOCAL_IDS ||
24802483
arg.getArgType() == KernelArg::ArgType::RT_STACK_ID) &&

IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,13 @@ bool KernelArg::isBindlessSampler(const Argument* arg, const StringRef typeStr)
686686
return (typeStr.equals("bindless_sampler_t"));
687687
}
688688

689+
bool KernelArg::isArgPtrType()
690+
{
691+
return m_argType == ArgType::PTR_LOCAL || m_argType == ArgType::PTR_GLOBAL
692+
|| m_argType == ArgType::PTR_CONSTANT || m_argType == ArgType::PTR_DEVICE_QUEUE;
693+
}
694+
695+
689696
iOpenCL::DATA_PARAMETER_TOKEN KernelArg::getDataParamToken() const
690697
{
691698
auto iter = argTypeTokenMap.find(m_argType);

IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ namespace IGC
221221
size_t getAlignment() const;
222222
bool isConstantBuf() const;
223223
bool needsAllocation() const;
224-
const llvm::Argument* getArg() const;
224+
const llvm::Argument* getArg() const;
225225
unsigned int getAssociatedArgNo() const;
226226
unsigned int getStructArgOffset() const;
227227
unsigned int getLocationIndex() const;
@@ -263,6 +263,10 @@ namespace IGC
263263
static bool isImage(const llvm::Argument* arg, const llvm::StringRef typeStr, ArgType& imageArgType);
264264
static bool isSampler(const llvm::Argument* arg, const llvm::StringRef typeStr);
265265

266+
/// @brief Checks whether the given argument is a sampler
267+
/// @return true is argument type is PTR_LOCAL | PTR_GLOBAL | PTR_CONSTANT | PTR_DEVICE_QUEUE
268+
bool isArgPtrType();
269+
266270
private:
267271
/// @brief Calculates the allocation size needed for the given explicit argument
268272
/// @param arg The kernel argument
@@ -329,7 +333,7 @@ namespace IGC
329333
/// @brief Indicates whether the argument is used in calculating the constant buffer length
330334
bool m_isConstantBuf;
331335
/// @brief The LLVM argument that represents this kernel argument
332-
const llvm::Argument* m_arg;
336+
const llvm::Argument* m_arg;
333337
/// @brief The argument number of the associated argument
334338
/// For image dimension/BUFFER_OFFSET arguments this will return the argument number
335339
/// of the assocaited image.

0 commit comments

Comments
 (0)