Changeset 3361 in CLRX


Ignore:
Timestamp:
Sep 12, 2017, 8:13:15 PM (15 months ago)
Author:
matszpk
Message:

CLRadeonExtender: enable STDC_MACROS for MinGW in Config.h. Own call_once implementation for mingw.

Location:
CLRadeonExtender/trunk
Files:
8 edited

Legend:

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

    r3360 r3361  
    237237#endif
    238238
    239 #if __cplusplus < 201103L || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
     239#if __cplusplus < 201103L || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) || defined(HAVE_MINGW)
    240240#define __STDC_LIMIT_MACROS 1
    241241#define __STDC_FORMAT_MACROS 1
  • CLRadeonExtender/trunk/CLRX/utils/Utilities.h

    r3205 r3361  
    947947    toUpperString(string.begin()); }
    948948
    949 };
    950 
     949/* CALL once */
     950
     951#ifndef HAVE_MINGW
     952typedef std::once_flag OnceFlag;
     953
     954template<class Callable, class... Args>
     955void callOnce(std::once_flag& flag, Callable&& f, Args&&... args)
     956{ std::call_once(flag, f, args...); }
     957#else
     958typedef std::atomic<int> OnceFlag;
     959
     960template<class Callable, class... Args>
     961void callOnce(OnceFlag& flag, Callable&& f, Args&&... args)
     962{
     963    if (flag.exchange(1) == 0)
     964        f(args...);
     965}
    951966#endif
     967
     968};
     969
     970#endif
  • CLRadeonExtender/trunk/amdasm/GCNAssembler.cpp

    r3344 r3361  
    2626#include <mutex>
    2727#include <CLRX/amdasm/Assembler.h>
     28#include <CLRX/utils/Utilities.h>
    2829#include "GCNAsmInternals.h"
    2930
    3031using namespace CLRX;
    3132
    32 static std::once_flag clrxGCNAssemblerOnceFlag;
     33static OnceFlag clrxGCNAssemblerOnceFlag;
    3334static Array<GCNAsmInstruction> gcnInstrSortedTable;
    3435
     
    345346                    getGPUArchitectureFromDeviceType(assembler.getDeviceType())))
    346347{
    347     std::call_once(clrxGCNAssemblerOnceFlag, initializeGCNAssembler);
     348    callOnce(clrxGCNAssemblerOnceFlag, initializeGCNAssembler);
    348349}
    349350
  • CLRadeonExtender/trunk/amdasm/GCNDisasm.cpp

    r3311 r3361  
    122122using namespace CLRX;
    123123
    124 static std::once_flag clrxGCNDisasmOnceFlag;
     124static OnceFlag clrxGCNDisasmOnceFlag;
    125125static std::unique_ptr<GCNInstruction[]> gcnInstrTableByCode = nullptr;
    126126
     
    247247        : ISADisassembler(disassembler), instrOutOfCode(false)
    248248{
    249     std::call_once(clrxGCNDisasmOnceFlag, initializeGCNDisassembler);
     249    callOnce(clrxGCNDisasmOnceFlag, initializeGCNDisassembler);
    250250}
    251251
  • CLRadeonExtender/trunk/clwrapper/CLFunctions1.cpp

    r2682 r3361  
    286286    CLRXPlatform* p = static_cast<CLRXPlatform*>(platform);
    287287    try
    288     { std::call_once(p->onceFlag, clrxPlatformInitializeDevices, p); }
     288    { callOnce(p->onceFlag, clrxPlatformInitializeDevices, p); }
    289289    catch(const std::exception& ex)
    290290    { clrxAbort("Fatal error at device initialization: ", ex.what()); }
     
    619619       
    620620        try
    621         { std::call_once(platform->onceFlag, clrxPlatformInitializeDevices, platform); }
     621        { callOnce(platform->onceFlag, clrxPlatformInitializeDevices, platform); }
    622622        catch(const std::exception& ex)
    623623        { clrxAbort("Fatal error at device initialization: ", ex.what()); }
  • CLRadeonExtender/trunk/clwrapper/CLFunctions2.cpp

    r2682 r3361  
    13691369       
    13701370        try
    1371         { std::call_once(platform->onceFlag, clrxPlatformInitializeDevices, platform); }
     1371        { callOnce(platform->onceFlag, clrxPlatformInitializeDevices, platform); }
    13721372        catch(const std::exception& ex)
    13731373        { clrxAbort("Fatal error at device initialization: ", ex.what()); }
  • CLRadeonExtender/trunk/clwrapper/CLInternals.cpp

    r3297 r3361  
    4343using namespace CLRX;
    4444
    45 std::once_flag clrxOnceFlag;
     45OnceFlag clrxOnceFlag;
    4646bool useCLRXWrapper = true;
    4747/* use pure pointer - AMDOCL library must be available to end of program,
  • CLRadeonExtender/trunk/clwrapper/CLWrapper.h

    r2682 r3361  
    176176{
    177177    cl_platform_id amdOclPlatform;
    178     std::once_flag onceFlag; // for synchronization
     178    CLRX::OnceFlag onceFlag; // for synchronization
    179179    std::unique_ptr<char[]> extensions;
    180180    size_t extensionsSize;
     
    400400
    401401/* internals */
    402 CLRX_INTERNAL extern std::once_flag clrxOnceFlag;
     402CLRX_INTERNAL extern CLRX::OnceFlag clrxOnceFlag;
    403403CLRX_INTERNAL extern bool useCLRXWrapper;
    404404CLRX_INTERNAL extern cl_uint amdOclNumPlatforms;
     
    523523    { \
    524524        try \
    525         { std::call_once(clrxOnceFlag, clrxWrapperInitialize); } \
     525        { CLRX::callOnce(clrxOnceFlag, clrxWrapperInitialize); } \
    526526        catch(const std::exception& ex) \
    527527        { \
     
    543543    { \
    544544        try \
    545         { std::call_once(clrxOnceFlag, clrxWrapperInitialize); } \
     545        { CLRX::callOnce(clrxOnceFlag, clrxWrapperInitialize); } \
    546546        catch(const std::exception& ex) \
    547547        { \
     
    567567    { \
    568568        try \
    569         { std::call_once(clrxOnceFlag, clrxWrapperInitialize); } \
     569        { CLRX::callOnce(clrxOnceFlag, clrxWrapperInitialize); } \
    570570        catch(const std::exception& ex) \
    571571        { \
Note: See TracChangeset for help on using the changeset viewer.