Пример #1
0
oclQuantize::oclQuantize(oclContext& iContext, oclProgram* iParent)
: oclProgram(iContext, "oclQuantize", iParent)
// kernels
, clQuantizeLAB(*this, "clQuantizeLAB")
{
    addSourceFile("color/oclQuantize.cl");
}
Пример #2
0
oclColor::oclColor(oclContext& iContext, oclProgram* iParent)
: oclProgram(iContext, "oclColor", iParent)
// kernels
, clHSVtoRGB(*this, "clHSVtoRGB")
, clRGBtoHSV(*this, "clRGBtoHSV")

, clRGBtoXYZ(*this, "clRGBtoXYZ")
, clXYZtoRGB(*this, "clXYZtoRGB")

, clRGBtoLAB(*this, "clRGBtoLAB")
, clLABtoRGB(*this, "clLABtoRGB")
{
    addSourceFile("color/oclColor.cl");
}
Пример #3
0
oclConvolute::oclConvolute(oclContext& iContext)
: oclProgram(iContext, "oclConvolute")
// kernels
, clIso2D(*this)
, clIso2Dsep(*this)
, clAniso2Dtang(*this)
, clAniso2Dorth(*this)
{
    exportKernel(clIso2D);
    exportKernel(clIso2Dsep);
    exportKernel(clAniso2Dtang);
    exportKernel(clAniso2Dorth);

    addSourceFile("filter/oclConvolute.cl");
}
Пример #4
0
oclBloom::oclBloom(oclContext& iContext, oclProgram* iParent)
: oclProgram(iContext, "oclBloom", iParent)
, mGaussian(iContext, this)
// buffers
, bfTempA(iContext, "bfTemp0")
, bfTempB(iContext, "bfTemp1")
// kernels
, clFilter(*this, "clFilter")
, clCombine(*this, "clCombine")
{
    bfTempA.create(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, sDefaultFormat, 256, 256);
    bfTempB.create(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, sDefaultFormat, 256, 256);

    addSourceFile("image/oclBloom.cl");
}
oclBilinearPyramid::oclBilinearPyramid(oclContext& iContext)
: oclProgram(iContext, "oclBilinearPyramid")
// kernels
, clUpsample(*this)
, clDownsample(*this)
, mLevel(1)
{
	addSourceFile("filter/oclBilinearPyramid.cl");

	exportKernel(clUpsample);
	exportKernel(clDownsample);

    cl_image_format lFormat = { CL_RGBA,  CL_HALF_FLOAT };
    mLevel[0] = new oclImage2D(mContext, "Level");
    mLevel[0]->create(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, lFormat, 256, 256);
}
Пример #6
0
oclToneMapping::oclToneMapping(oclContext& iContext, oclProgram* iParent)
    : oclProgram(iContext, "oclToneMapping", iParent)
// buffers
    , bfTempA(iContext, "bfTempA")
    , bfTempB(iContext, "bfTempB")
// kernels
    , clCombine(*this, "clCombine")
// programs
    , mColor(iContext, this)
    , mPyramid(iContext, this)
    , mMemory(iContext, this)
{
    cl_image_format lFormat = { CL_RGBA,  CL_HALF_FLOAT };
    bfTempA.create(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, lFormat, 256, 256);
    bfTempB.create(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, lFormat, 256, 256);

    addSourceFile("image/oclToneMapping.cl");
}
Пример #7
0
oclBvhTrimesh::oclBvhTrimesh(oclContext& iContext)
  : oclProgram(iContext, "oclBvhTrimesh")
    // buffers
  , bfAABB(iContext, "bfAABB")
  , bfMortonKey(iContext, "bfMortonKey")
  , bfMortonVal(iContext, "bfMortonVal")
  , bfBvhRoot(iContext, "bfBvhRoot")
  , bfBvhNode(iContext, "bfBvhNode")
    // kernels
  , clAABB(*this)
  , clMorton(*this)
  , clCreateNodes(*this)
  , clLinkNodes(*this)
  , clCreateLeaves(*this)
  , clComputeAABBs(*this)
    // programs
  , mRadixSort(iContext)
    // members
  , mRootNode(0)
{
	bfAABB.create<srtAABB>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
	bfMortonKey.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 256);
	bfMortonVal.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 256);
	bfBvhNode.create<cl_char>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
	bfBvhRoot.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 1, 
                              &mRootNode);

	addSourceFile("geom/oclBvhTrimesh.cl");

	exportKernel(clAABB);
	exportKernel(clMorton);
	exportKernel(clCreateNodes);
	exportKernel(clLinkNodes);
	exportKernel(clCreateLeaves);
	exportKernel(clComputeAABBs);
}
Пример #8
0
oclFluid3D::oclFluid3D(oclContext& iContext)
: oclProgram(iContext, "oclFluid3D")
// buffers
, bfCell(iContext, "bfCell")
, bfCellStart(iContext, "bfCellStart")
, bfCellEnd(iContext, "bfCellEnd")
, bfIndex(iContext, "bfIndex")
, bfSortedPosition(iContext, "bfSortedPosition")
, bfSortedVelocity(iContext, "bfSortedVelocity")
, bfParams(iContext, "bfParams")
, bfPosition(0)
, bfVelocity(0)
, bfForce(0)
// kernels
, clIntegrateForce(*this)
, clIntegrateVelocity(*this)
, clHash(*this)
, clReorder(*this)
, clInitBounds(*this)
, clFindBounds(*this)
, clCalculateDensity(*this)
, clCalculateForces(*this)
, clInitFluid(*this)
, clClipBox(*this)
, clGravity(*this)
// programs
, mRadixSort(iContext)
// members
, mParticleCount(cLocalSize)
, mIntegrateCb(0)
{
	bfCell.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfCellStart.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, cBucketCount);
	bfCellEnd.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, cBucketCount);
	bfIndex.create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfSortedPosition.create<cl_float4>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfSortedVelocity.create<cl_float4>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfParams.create<Params>(CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 1, &mParams);

   /*
    oclBuffer* ll = new oclBuffer(iContext, "dsdsdsdsd");
    for (int i=0; i<100; i++)
    {
        ll->create<cl_uint>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, cBucketCount);
        delete ll;
        ll = new oclBuffer(iContext, "dsdsdsdsd");
    }
    */
    

	bfPosition = new oclBuffer(iContext, "bfPosition");
	bfPosition->setOwner(this); 
	bfVelocity = new oclBuffer(iContext, "bfVelocity");
	bfVelocity->setOwner(this);
	bfForce = new oclBuffer(iContext, "bfForce");
	bfForce->setOwner(this); 
 
	bfPosition->create<cl_float4>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfVelocity->create<cl_float4>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);
	bfForce->create<cl_float4>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mParticleCount);

	addSourceFile("phys/oclFluid3D.cl");

	exportKernel(clClipBox);
	exportKernel(clGravity);
	exportKernel(clIntegrateForce);
	exportKernel(clIntegrateVelocity);
}
Пример #9
0
oclRbm::oclRbm(oclContext& iContext, oclProgram* iParent)
    : oclProgram(iContext, "oclRbm", iParent)
// buffers
    , bfVis0(iContext, "bfVis0")
    , bfVisN(iContext, "bfVisN")
    , bfError(iContext, "bfError", oclBuffer::_float)
    , bfC(iContext, "bfC")
    , bfWtemp(iContext, "bfWtemp")

    , bfTempA(iContext, "bfTempA", oclBuffer::_float)
    , bfTTT(iContext, "bfTTT", oclBuffer::_float)

    , bfMaps(0)
    , bfBernoulli(iContext, "bfBernoulli", oclBuffer::_float)
// kernels
    , clGetMap(*this, "clGetMap")
    , clGetVis(*this, "clGetVis")
    , clGetWeight(*this, "clGetWeight")

    , clLoadImage(*this, "clLoadImage")
    , clGetImage(*this, "clGetImage")

    , clGibbsUpA(*this, "clGibbsUpA")
    , clGibbsUpB(*this, "clGibbsUpB")
    , clGibbsDnA(*this, "clGibbsDnA")
    , clGibbsDnB0(*this, "clGibbsDnB0")
    , clGibbsDnB1(*this, "clGibbsDnB1")
    , clGibbsDnC(*this, "clGibbsDnC")
    , clError(*this, "clError")

    , clDwA(*this, "clDwA")
    , clDwB(*this, "clDwB")
    , clDc(*this, "clDc")
    , clDb(*this, "clDb")
    , clLearn(*this, "clLearn")

    , clSparsity(*this, "clSparsity")

// programs
    , mMemory(iContext, this)

    , mKernelW(5)
    , mKernelH(5)
    , mInputW(0)
    , mInputH(0)

    , mRate(0.01f)
    , mMomentum(0.0f)
    , mPenalty(0.05f)
    , mSparsity(0.02f)
{
    //cl_image_format lFormat = { CL_RGBA,  CL_HALF_FLOAT };
    bfVis0.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 256 * 256);
    bfVisN.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 256 * 256);
    bfBernoulli.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 256 * 256);
    bfError.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
    bfTTT.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
    bfWtemp.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);

    bfC.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
    bfDc[0] = new oclBuffer(iContext, "bfDc0");
    bfDc[0]->create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);
    bfDc[1] = new oclBuffer(iContext, "bfDc1");
    bfDc[1]->create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, 1);

    bfTempA.create<cl_float>(CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, mKernelW*mKernelH);

    addSourceFile("learning/oclRbm.cl");
}
Пример #10
0
static void doSetCompilerPath(const char * path, const char * includes, const char * libs, const char * tmpdir, unsigned targetCompiler, bool verbose)
{
    if (!includes)
        includes = INCLUDEPATH[targetCompiler];
    if (!libs)
        libs = LIB_DIR[targetCompiler];
    if (verbose)
    {
        PrintLog("Include directory set to %s", includes);
        PrintLog("Library directory set to %s", libs);
    }
    compilerRoot.set(path ? path : targetCompiler==GccCppCompiler ? "/usr" : ".\\CL");
    stdIncludes.set(includes);
    stdLibs.clear();
    for (;;)
    {
        StringBuffer thislib;
        while (*libs && *libs != ';')
            thislib.append(*libs++);
        if (thislib.length())
        {
            stdLibs.append(" ").append(USE_LIBPATH_FLAG[targetCompiler]).append(thislib).append(USE_LIBPATH_TAIL[targetCompiler]);
            if (USE_LIBRPATH_FLAG[targetCompiler])
                stdLibs.append(" ").append(USE_LIBRPATH_FLAG[targetCompiler]).append(thislib);
        }
        if (!*libs)
            break;
        libs++;
    }
    StringBuffer fname;
    if (path)
    {
        const char *finger = CC_NAME[targetCompiler];
        while (*finger)
        {
            if (*finger == '#')
                fname.append(path);
            else
                fname.append(*finger);
            finger++;
        }

#if defined(__linux__)
        StringBuffer clbin_dir;
        const char* dir_end = strrchr(fname, '/');
        if(dir_end == NULL)
            clbin_dir.append(".");
        else
            clbin_dir.append((dir_end - fname.str()) + 1, fname.str());
        
        StringBuffer pathenv(clbin_dir.str());
        const char* oldpath = getenv("PATH");
        if(oldpath != NULL && *oldpath != '\0')
        pathenv.append(":").append(oldpath);
        setenv("PATH", pathenv.str(), 1);
#endif
    }
    else
    {
        fname.append(compilerRoot).append(CC_NAME[targetCompiler]);
        fname.replaceString("#",NULL);
    }
    if (verbose)
        PrintLog("Compiler path set to %s", fname.str());

    dequote(fname);
#ifdef _WIN32
    if (_access(fname.str(), 4))
    {
#else
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
    struct stat filestatus;
    int r = stat(fname.str(), &filestatus);
    if (    (r != 0)
        ||  (!S_ISREG(filestatus.st_mode))
        ||  (filestatus.st_mode&(S_IXOTH|S_IXGRP|S_IXUSR)==0))
    {
        if (r == -1) errno = ENOENT;
#endif
#endif
        if (verbose)
            PrintLog("SetCompilerPath - no compiler found");
        throw MakeOsException(GetLastError(), "setCompilerPath could not locate compiler %s", fname.str());
    }

    if(tmpdir && *tmpdir)
    {
        //MORE: this should be done for the child process instead of the parent but invoke does not let me do it
#if defined(__linux__)
        setenv("TMPDIR", tmpdir, 1);
#endif

#ifdef _WIN32
        StringBuffer tmpbuf;
        tmpbuf.append("TMP=").append(tmpdir);
        _putenv(tmpbuf.str());
#endif
    }
}

//===========================================================================

class CCompilerThreadParam : CInterface
{
public:
    IMPLEMENT_IINTERFACE;
    CCompilerThreadParam(const StringBuffer & _cmdline, Semaphore & _finishedCompiling, const StringBuffer & _logfile) : cmdline(_cmdline), finishedCompiling(_finishedCompiling), logfile(_logfile) {};

    StringBuffer        cmdline;
    StringBuffer        logfile;
    Semaphore       &   finishedCompiling;
};

//===========================================================================

static void setDirectoryPrefix(StringAttr & target, const char * source)
{
    if (source && *source)
    {
        StringBuffer temp;
        target.set(addDirectoryPrefix(temp, source));
    }
}

CppCompiler::CppCompiler(const char * _coreName, const char * _sourceDir, const char * _targetDir, unsigned _targetCompiler, bool _verbose)
{
#define CORE_NAME allSources.item(0)
    if (_coreName)
        addSourceFile(_coreName);
    targetCompiler = _targetCompiler;
    createDLL = true;
#ifdef _DEBUG
    setDebug(true);
    setDebugLibrary(true);
#else
    setDebug(false);
    setDebugLibrary(false);
#endif
    
    setDirectoryPrefix(sourceDir, _sourceDir);
    setDirectoryPrefix(targetDir, _targetDir);
    maxCompileThreads = 1;
    onlyCompile = false;
    verbose = _verbose;
    saveTemps = false;
    abortChecker = NULL;
}

void CppCompiler::addCompileOption(const char * option)
{
    compilerOptions.append(' ').append(option);
}
Пример #11
0
void QMakeSourceFileInfo::addSourceFiles(const QStringList &l, uchar seek,
                                         QMakeSourceFileInfo::SourceFileType type)
{
    for(int i=0; i<l.size(); ++i)
        addSourceFile(l.at(i), seek, type);
}