///////////////////////////////////////////////////////////////////////////
GenContext::GenContext(const ir::Unit &unit,
const std::string &name,
- bool limitRegisterPressure) :
- Context(unit, name), limitRegisterPressure(limitRegisterPressure)
+ bool limitRegisterPressure,
+ bool relaxMath) :
+ Context(unit, name), limitRegisterPressure(limitRegisterPressure), relaxMath(relaxMath)
{
this->p = GBE_NEW(GenEncoder, simdWidth, 7); // XXX handle more than Gen7
this->sel = GBE_NEW(Selection, *this);
/*! Create a new context. name is the name of the function we want to
* compile
*/
- GenContext(const ir::Unit &unit, const std::string &name, bool limitRegisterPressure = false);
+ GenContext(const ir::Unit &unit, const std::string &name, bool limitRegisterPressure = false, bool relaxMath = false);
/*! Release everything needed */
~GenContext(void);
/*! Implements base class */
* regenerating the code
*/
bool limitRegisterPressure;
+ bool relaxMath;
private:
/*! Build the curbe patch list for the given kernel */
void buildPatchList(void);
// XXX TODO: we need a clean support of FP_CONTRACT to remove below line 'return false'
// if 'pragma FP_CONTRACT OFF' is used in cl kernel, we should not do mad optimization.
- return false;
+ if (!sel.ctx.relaxMath)
+ return false;
// MAD tend to increase liveness of the sources (since there are three of
// them). TODO refine this strategy. Well, we should be able at least to
// evaluate per basic block register pressure and selectively enable
{8,true},
};
- Kernel *GenProgram::compileKernel(const ir::Unit &unit, const std::string &name) {
+ Kernel *GenProgram::compileKernel(const ir::Unit &unit, const std::string &name, bool relaxMath) {
// Be careful when the simdWidth is forced by the programmer. We can see it
// when the function already provides the simd width we need to use (i.e.
// Force the SIMD width now and try to compile
unit.getFunction(name)->setSimdWidth(simdWidth);
- Context *ctx = GBE_NEW(GenContext, unit, name, limitRegisterPressure);
+ Context *ctx = GBE_NEW(GenContext, unit, name, limitRegisterPressure, relaxMath);
kernel = ctx->compileKernel();
if (kernel != NULL) {
break;
/*! Destroy the program */
virtual ~GenProgram(void);
/*! Implements base class */
- virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name);
+ virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name, bool relaxMath);
/*! Allocate an empty kernel. */
virtual Kernel *allocateKernel(const std::string &name) {
return GBE_NEW(GenKernel, name);
return true;
}
+ BVAR(OCL_STRICT_CONFORMANCE, true);
+
bool Program::buildFromUnit(const ir::Unit &unit, std::string &error) {
constantSet = new ir::ConstantSet(unit.getConstantSet());
const auto &set = unit.getFunctionSet();
if (kernelNum == 0) return true;
for (const auto &pair : set) {
const std::string &name = pair.first;
- Kernel *kernel = this->compileKernel(unit, name);
+ Kernel *kernel = this->compileKernel(unit, name, !OCL_STRICT_CONFORMANCE);
kernel->setSamplerSet(pair.second->getSamplerSet());
kernel->setImageSet(pair.second->getImageSet());
kernel->setCompileWorkGroupSize(pair.second->getCompileWorkGroupSize());
}
BVAR(OCL_OUTPUT_BUILD_LOG, false);
- BVAR(OCL_STRICT_CONFORMANCE, true);
SVAR(OCL_PCH_PATH, PCH_OBJECT_DIR);
SVAR(OCL_PCM_PATH, PCM_OBJECT_DIR);
protected:
/*! Compile a kernel */
- virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name) = 0;
+ virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name, bool relaxMath) = 0;
/*! Allocate an empty kernel. */
virtual Kernel *allocateKernel(const std::string &name) = 0;
/*! Kernels sorted by their name */