Changeset 3199 in CLRX


Ignore:
Timestamp:
Jun 27, 2017, 9:04:51 PM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: find amdocl in many library paths by default for make CLRX to be working on many Linux distros.

Location:
CLRadeonExtender/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/Config.h.in

    r3078 r3199  
    139139
    140140#  ifdef HAVE_32BIT
     141#    define DEFAULT_AMDOCLNAME "libamdocl32.so"
    141142#    ifdef HAVE_UBUNTU_GPUPRO
    142143#    define DEFAULT_AMDOCLPATH "/usr/lib/i386-linux-gnu/amdgpu-pro/libamdocl32.so"
     
    149150#    endif
    150151#  else
     152#    define DEFAULT_AMDOCLNAME "libamdocl64.so"
    151153#    ifdef HAVE_UBUNTU_GPUPRO
    152154#    define DEFAULT_AMDOCLPATH "/usr/lib/x86_64-linux-gnu/amdgpu-pro/libamdocl64.so"
     
    170172
    171173#  ifdef HAVE_32BIT
     174#  define DEFAULT_AMDOCLNAME "amdocl.dll"
    172175#  define DEFAULT_AMDOCLPATH "c:\\Windows\\System32\\amdocl.dll"
    173176#  else
     177#  define DEFAULT_AMDOCLNAME "amdocl64.dll"
    174178#  define DEFAULT_AMDOCLPATH "c:\\Windows\\System32\\amdocl64.dll"
    175179#  endif
  • CLRadeonExtender/trunk/CLRX/utils/Utilities.h

    r2682 r3199  
    683683/// returns true if path refers to directory
    684684extern bool isDirectory(const char* path);
     685/// returns true if file exists
     686extern bool isFileExists(const char* path);
    685687
    686688/// load data from file (any regular or pipe or device)
     
    706708/// create directory
    707709extern void makeDir(const char* dirname);
     710/// find amdocl library, returns path if found, otherwise returns empty string
     711extern std::string findAmdOCL();
    708712
    709713/*
  • CLRadeonExtender/trunk/amdbin/AmdBinGen.cpp

    r3069 r3199  
    18321832{
    18331833    std::lock_guard<std::mutex> lock(detectionMutex);
    1834     std::string amdOclPath = parseEnvVariable<std::string>("CLRX_AMDOCL_PATH",
    1835                            DEFAULT_AMDOCLPATH);
     1834    std::string amdOclPath = findAmdOCL();
    18361835   
    18371836    bool notThisSameFile = false;
  • CLRadeonExtender/trunk/clwrapper/CLInternals.cpp

    r2999 r3199  
    304304    {
    305305        useCLRXWrapper = !parseEnvVariable<bool>("CLRX_FORCE_ORIGINAL_AMDOCL", false);
    306         std::string amdOclPath = parseEnvVariable<std::string>("CLRX_AMDOCL_PATH",
    307                            DEFAULT_AMDOCLPATH);
     306        std::string amdOclPath = findAmdOCL();
    308307        /// set temporary amd ocl library
    309308        tmpAmdOclLibrary.reset(new DynLibrary(amdOclPath.c_str(), DYNLIB_NOW));
  • CLRadeonExtender/trunk/utils/Utilities.cpp

    r2682 r3199  
    389389}
    390390
     391/// returns true if file exists
     392bool CLRX::isFileExists(const char* path)
     393{
     394#ifdef HAVE_WINDOWS
     395    return PathFileExists(path);
     396#else
     397    return ::access(path, F_OK)==0;
     398#endif
     399}
     400
    391401Array<cxbyte> CLRX::loadDataFromFile(const char* filename)
    392402{
     
    542552    }
    543553}
     554
     555static const char* libAmdOCLPaths[] =
     556{
     557#ifdef HAVE_LINUX
     558#  ifdef HAVE_32BIT
     559     "/usr/lib/i386-linux-gnu/amdgpu-pro",
     560     "/opt/amdgpu-pro/lib/i386-linux-gnu",
     561     "/opt/amdgpu-pro/lib",
     562     "/usr/lib32",
     563     "/usr/lib"
     564#  else
     565     "/usr/lib/x86_64-linux-gnu/amdgpu-pro",
     566     "/opt/amdgpu-pro/lib/x86_64-linux-gnu",
     567     "/opt/amdgpu-pro/lib64",
     568     "/usr/lib64"
     569#  endif
     570#elif defined(HAVE_WINDOWS)
     571     "c:\\Windows\\System32"
     572#endif
     573};
     574
     575std::string CLRX::findAmdOCL()
     576{
     577    std::string amdOclPath = parseEnvVariable<std::string>("CLRX_AMDOCL_PATH", "");
     578    if (!amdOclPath.empty() && isFileExists(amdOclPath.c_str()))
     579        return amdOclPath;
     580    else if (isFileExists(DEFAULT_AMDOCLPATH))
     581        return DEFAULT_AMDOCLPATH;
     582    else
     583        for (const char* libPath: libAmdOCLPaths)
     584        {
     585            amdOclPath = joinPaths(libPath, DEFAULT_AMDOCLNAME);
     586            if (isFileExists(amdOclPath.c_str()))
     587                return amdOclPath;
     588        }
     589    return "";
     590}
Note: See TracChangeset for help on using the changeset viewer.