Changeset 3309 in CLRX


Ignore:
Timestamp:
Sep 5, 2017, 12:57:19 PM (15 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmGallium?: Add 'default_hsa_features' to set default HSA features and register features. Update samples and docs.

Location:
CLRadeonExtender/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmGalliumFormat.cpp

    r3308 r3309  
    4242    "debug_private_segment_buffer_sgpr",
    4343    "debug_wavefront_private_segment_offset_sgpr",
    44     "debugmode", "dims", "driver_version", "dx10clamp",
     44    "debugmode", "default_hsa_features",
     45    "dims", "driver_version", "dx10clamp",
    4546    "entry", "exceptions", "floatmode", "gds_segment_size",
    4647    "get_driver_version", "get_llvm_version", "globaldata",
     
    8485    GALLIUMOP_DEBUG_PRIVATE_SEGMENT_BUFFER_SGPR,
    8586    GALLIUMOP_DEBUG_WAVEFRONT_PRIVATE_SEGMENT_OFFSET_SGPR,
    86     GALLIUMOP_DEBUGMODE, GALLIUMOP_DIMS, GALLIUMOP_DRIVER_VERSION, GALLIUMOP_DX10CLAMP,
     87    GALLIUMOP_DEBUGMODE, GALLIUMOP_DEFAULT_HSA_FEATURES,
     88    GALLIUMOP_DIMS, GALLIUMOP_DRIVER_VERSION, GALLIUMOP_DX10CLAMP,
    8789    GALLIUMOP_ENTRY, GALLIUMOP_EXCEPTIONS, GALLIUMOP_FLOATMODE, GALLIUMOP_GDS_SEGMENT_SIZE,
    8890    GALLIUMOP_GET_DRIVER_VERSION, GALLIUMOP_GET_LLVM_VERSION, GALLIUMOP_GLOBALDATA,
     
    830832}
    831833
     834void AsmGalliumPseudoOps::setDefaultHSAFeatures(AsmGalliumHandler& handler,
     835                    const char* pseudoOpPlace, const char* linePtr)
     836{
     837    Assembler& asmr = handler.assembler;
     838    if (asmr.currentKernel==ASMKERN_GLOBAL ||
     839        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     840    {
     841        asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
     842        return;
     843    }
     844    if (handler.determineLLVMVersion() < 40000U)
     845    {
     846        asmr.printError(pseudoOpPlace, "HSA configuration pseudo-op only for LLVM>=4.0.0");
     847        return;
     848    }
     849   
     850    if (!checkGarbagesAtEnd(asmr, linePtr))
     851        return;
     852   
     853    handler.kernelStates[asmr.currentKernel]->initializeAmdHsaKernelConfig();
     854    AsmAmdHsaKernelConfig* config = handler.kernelStates[asmr.currentKernel]->config.get();
     855    config->enableSgprRegisterFlags =
     856                    uint16_t(AMDHSAFLAG_USE_PRIVATE_SEGMENT_BUFFER|
     857                        AMDHSAFLAG_USE_DISPATCH_PTR|AMDHSAFLAG_USE_KERNARG_SEGMENT_PTR);
     858    config->enableFeatureFlags = uint16_t(AMDHSAFLAG_USE_PTR64|2);
     859}
     860
    832861void AsmGalliumPseudoOps::setMachine(AsmGalliumHandler& handler, const char* pseudoOpPlace,
    833862                      const char* linePtr)
     
    14091438                                GALLIUMCVAL_DEBUGMODE);
    14101439            break;
     1440        case GALLIUMOP_DEFAULT_HSA_FEATURES:
     1441            AsmGalliumPseudoOps::setDefaultHSAFeatures(*this, stmtPlace, linePtr);
     1442            break;
    14111443        case GALLIUMOP_DIMS:
    14121444            AsmGalliumPseudoOps::setDimensions(*this, stmtPlace, linePtr, false);
     
    19331965            AmdHsaKernelConfig outConfig;
    19341966            ::memset(&outConfig, 0xff, 128); // fill by defaults
    1935             outConfig.enableSgprRegisterFlags =
    1936                     uint16_t(AMDHSAFLAG_USE_PRIVATE_SEGMENT_BUFFER|
    1937                         AMDHSAFLAG_USE_DISPATCH_PTR|AMDHSAFLAG_USE_KERNARG_SEGMENT_PTR);
    1938             outConfig.enableFeatureFlags = uint16_t(AMDHSAFLAG_USE_PTR64|2);
    19391967           
    19401968            const Kernel& kernel = *kernelStates[ki];
     
    19661994                    // scratch buffer
    19671995                    config.scratchBufferSize = hsaConfig.workitemPrivateSegmentSize;
    1968                
    1969                 if (outConfig.enableSgprRegisterFlags == 0)
    1970                     outConfig.enableSgprRegisterFlags =
    1971                         uint16_t(AMDHSAFLAG_USE_PRIVATE_SEGMENT_BUFFER|
    1972                             AMDHSAFLAG_USE_DISPATCH_PTR|AMDHSAFLAG_USE_KERNARG_SEGMENT_PTR);
    1973                 if (outConfig.enableFeatureFlags == 0)
    1974                     outConfig.enableFeatureFlags = uint16_t(AMDHSAFLAG_USE_PTR64|2);
    19751996            }
    19761997           
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r3297 r3309  
    395395                      const char* linePtr, GalliumConfigValueTarget target);
    396396   
     397    static void setDefaultHSAFeatures(AsmGalliumHandler& handler, const char* pseudoOpPlace,
     398                      const char* linePtr);
     399   
    397400    static void setDimensions(AsmGalliumHandler& handler, const char* pseudoOpPlace,
    398401                      const char* linePtr, bool amdHsa);
  • CLRadeonExtender/trunk/doc/ClrxAsmGallium.md

    r3308 r3309  
    173173Enable usage of the DEBUG_MODE.
    174174
     175### .default_hsa_features
     176
     177This pseudo-op must be inside kernel configuration (`.config`) and can ben used only if
     178LLVM version is 4.0.0 or later. It sets default HSA kernel features and register features
     179(extra SGPR registers usage).
     180
    175181### .dims
    176182
  • CLRadeonExtender/trunk/samples/ReverseBits.cpp

    r3267 r3309  
    250250        .arg gridoffset,4
    251251    .config
     252    .if LLVM_VERSION>=40000
     253        .dims x
     254        .dx10clamp
     255        .ieeemode
     256        .default_hsa_features
     257    .else
    252258        .dims xyz   # gallium set always three dimensions by Gallium
    253259        .tgsize     # TG_SIZE_EN is always enabled by Gallium
     260    .endif
    254261        # arg offset in dwords:
    255262        # 9 - n, 11 - abuf, 13 - bbuf, 15 - griddim, 16 - gridoffset
  • CLRadeonExtender/trunk/samples/VectorAdd.cpp

    r3266 r3309  
    255255        .dx10clamp
    256256        .ieeemode
     257        .default_hsa_features
    257258    .else
    258259        .dims xyz   # gallium set always three dimensions by Gallium
  • CLRadeonExtender/trunk/tests/amdasm/AsmGalliumFormat.cpp

    r3308 r3309  
    442442            .pgmrsrc2 523243
    443443            .scratchbuffer 230
     444            .default_hsa_features
    444445           
    445446            .call_convention 0x34dac
     
    462463            .ieeemode
    463464            .pgmrsrc2 0
     465            .default_hsa_features
    464466            .group_segment_align 128
    465467            .kernarg_segment_align 64
     
    626628      computePgmRsrc2=0x7fbd1
    627629      enableSgprRegisterFlags=0x20
    628       enableFeatureFlags=0xa
     630      enableFeatureFlags=0x0
    629631      workitemPrivateSegmentSize=230
    630632      workgroupGroupSegmentSize=22
     
    658660  Code:
    659661  0100000000000000010008000000030000010000000000000000000000000000
    660   00000000000000000000000000000000e2b58e00d1fb070020000a00e6000000
     662  00000000000000000000000000000000e2b58e00d1fb070020000000e6000000
    661663  16000000640000001000000000000000fc0c00003d008b000000000000000000
    662664  6000620005040406ac4d03000000000000000000000000000000000000000000
Note: See TracChangeset for help on using the changeset viewer.