Changeset 2586 in CLRX


Ignore:
Timestamp:
Nov 21, 2016, 6:59:04 PM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: DisasmROCm: replace '.use_grid_workgroup_count_?' by single '.use_grid_workgroup_count' with dimesions specification.
AsmRocm?: Adding specific pseudo-ops.

Location:
CLRadeonExtender/trunk/amdasm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r2583 r2586  
    531531                      const char* linePtr);
    532532   
     533    static void doControlDirective(AsmROCmHandler& handler, const char* pseudoOpPlace,
     534                      const char* linePtr);
     535   
    533536    static void setConfigValue(AsmROCmHandler& handler, const char* pseudoOpPlace,
    534537                      const char* linePtr, ROCmConfigValueTarget target);
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r2584 r2586  
    3232static const char* rocmPseudoOpNamesTbl[] =
    3333{
    34     "config", "debugmode", "dims", "dx10clamp",
    35     "exceptions", "floatmode",
    36     "ieeemode", "kcode", "kcodeend",
    37     "localsize", "pgmrsrc1", "pgmrsrc2", "priority",
    38     "privmode", "scratchbuffer", "sgprsnum", "tgsize",
    39     "userdatanum", "vgprsnum"
     34    "call_convention", "codeversion", "config",
     35    "control_directive", "debug_private_segment_buffer_sgpr",
     36    "debug_wavefront_private_segment_offset_sgpr",
     37    "debugmode", "dims", "dx10clamp",
     38    "exceptions", "floatmode", "gds_segment_size",
     39    "group_segment_align", "ieeemode", "kcode",
     40    "kcodeend", "kernarg_segment_align",
     41    "kernarg_segment_size", "kernel_code_entry_offset",
     42    "kernel_code_prefetch_offset", "kernel_code_prefetch_size",
     43    "localsize", "machine", "max_scratch_backing_memory",
     44    "pgmrsrc1", "pgmrsrc2", "priority", "private_segment_align",
     45    "privmode", "reserved_sgpr_count", "reserved_sgpr_first",
     46    "reserved_vgpr_count", "reserved_vgpr_first",
     47    "runtime_loader_kernel_symbol",
     48    "scratchbuffer", "sgprsnum", "tgsize",
     49    "use_debug_enabled", "use_dispatch_id",
     50    "use_dispatch_ptr", "use_dynamic_call_stack",
     51    "use_flat_scratch_init", "use_grid_workgroup_count",
     52    "use_kernarg_segment_ptr", "use_ordered_append_gds",
     53    "use_private_segment_size", "use_ptr64", "use_queue_ptr",
     54    "use_private_segment_buffer", "use_xnack_enabled",
     55    "userdatanum", "vgprsnum", "wavefront_sgpr_count",
     56    "wavefront_size", "workitem_vgpr_count",
     57    "workgroup_fbarrier_count", "workgroup_group_segment_size",
     58    "workitem_private_segment_size"
    4059};
    4160
     61enum
     62{
     63    ROCMOP_CALL_CONVENTION, ROCMOP_CODEVERSION, ROCMOP_CONFIG,
     64    ROCMOP_CONTROL_DIRECTIVE, ROCMOP_DEBUG_PRIVATE_SEGMENT_BUFFER_SGPR,
     65    ROCMOP_DEBUG_WAVEFRONT_PRIVATE_SEGMENT_OFFSET_SGPR,
     66    ROCMOP_DEBUGMODE, ROCMOP_DIMS, ROCMOP_DX10CLAMP,
     67    ROCMOP_EXCEPTIONS, ROCMOP_FLOATMODE, ROCMOP_GDS_SEGMENT_SIZE,
     68    ROCMOP_GROUP_SEGMENT_ALIGN, ROCMOP_IEEEMODE, ROCMOP_KCODE,
     69    ROCMOP_KCODEEND, ROCMOP_KERNARG_SEGMENT_ALIGN,
     70    ROCMOP_KERNARG_SEGMENT_SIZE, ROCMOP_KERNEL_CODE_ENTRY_OFFSET,
     71    ROCMOP_KERNEL_CODE_PREFETCH_OFFSET, ROCMOP_KERNEL_CODE_PREFETCH_SIZE,
     72    ROCMOP_LOCALSIZE, ROCMOP_MACHINE, ROCMOP_MAX_SCRATCH_BACKING_MEMORY,
     73    ROCMOP_PGMRSRC1, ROCMOP_PGMRSRC2, ROCMOP_PRIORITY, ROCMOP_PRIVATE_SEGMENT_ALIGN,
     74    ROCMOP_PRIVMODE, ROCMOP_RESERVED_SGPR_COUNT, ROCMOP_RESERVED_SGPR_FIRST,
     75    ROCMOP_RESERVED_VGPR_COUNT, ROCMOP_RESERVED_VGPR_FIRST,
     76    ROCMOP_RUNTIME_LOADER_KERNEL_SYMBOL,
     77    ROCMOP_SCRATCHBUFFER, ROCMOP_SGPRSNUM, ROCMOP_TGSIZE,
     78    ROCMOP_USE_DEBUG_ENABLED, ROCMOP_USE_DISPATCH_ID,
     79    ROCMOP_USE_DISPATCH_PTR, ROCMOP_USE_DYNAMIC_CALL_STACK,
     80    ROCMOP_USE_FLAT_SCRATCH_INIT, ROCMOP_USE_GRID_WORKGROUP_COUNT,
     81    ROCMOP_USE_KERNARG_SEGMENT_PTR, ROCMOP_USE_ORDERED_APPEND_GDS,
     82    ROCMOP_USE_PRIVATE_SEGMENT_SIZE, ROCMOP_USE_PTR64, ROCMOP_USE_QUEUE_PTR,
     83    ROCMOP_USE_PRIVATE_SEGMENT_BUFFER, ROCMOP_USE_XNACK_ENABLED,
     84    ROCMOP_USERDATANUM, ROCMOP_VGPRSNUM, ROCMOP_WAVEFRONT_SGPR_COUNT,
     85    ROCMOP_WAVEFRONT_SIZE, ROCMOP_WORKITEM_VGPR_COUNT,
     86    ROCMOP_WORKGROUP_FBARRIER_COUNT, ROCMOP_WORKGROUP_GROUP_SEGMENT_SIZE,
     87    ROCMOP_WORKITEM_PRIVATE_SEGMENT_SIZE
     88};
    4289
    4390/*
     
    195242    info.name = sections[sectionId].name;
    196243    return info;
    197 }
    198 
    199 bool AsmROCmHandler::parsePseudoOp(const CString& firstName,
    200        const char* stmtPlace, const char* linePtr)
    201 {
    202     return false;
    203244}
    204245
     
    247288bool AsmROCmPseudoOps::checkPseudoOpName(const CString& string)
    248289{
    249     return false;
    250 }
    251    
    252 /* user configuration pseudo-ops */
     290    if (string.empty() || string[0] != '.')
     291        return false;
     292    const size_t pseudoOp = binaryFind(rocmPseudoOpNamesTbl, rocmPseudoOpNamesTbl +
     293                sizeof(rocmPseudoOpNamesTbl)/sizeof(char*), string.c_str()+1,
     294               CStringLess()) - rocmPseudoOpNamesTbl;
     295    return pseudoOp < sizeof(rocmPseudoOpNamesTbl)/sizeof(char*);
     296}
     297   
    253298void AsmROCmPseudoOps::doConfig(AsmROCmHandler& handler, const char* pseudoOpPlace,
    254299                  const char* linePtr)
    255300{
     301    Assembler& asmr = handler.assembler;
     302    const char* end = asmr.line + asmr.lineSize;
     303    if (asmr.currentKernel==ASMKERN_GLOBAL)
     304    {
     305        asmr.printError(pseudoOpPlace, "Kernel config can be defined only inside kernel");
     306        return;
     307    }
     308   
     309    if (handler.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     310    {
     311        asmr.printError(pseudoOpPlace, "Configuration outside kernel definition");
     312        return;
     313    }
     314    skipSpacesToEnd(linePtr, end);
     315    if (!checkGarbagesAtEnd(asmr, linePtr))
     316        return;
     317}
     318
     319void AsmROCmPseudoOps::doControlDirective(AsmROCmHandler& handler,
     320              const char* pseudoOpPlace, const char* linePtr)
     321{
    256322}
    257323
     
    288354}
    289355
     356bool AsmROCmHandler::parsePseudoOp(const CString& firstName, const char* stmtPlace,
     357               const char* linePtr)
     358{
     359    const size_t pseudoOp = binaryFind(rocmPseudoOpNamesTbl, rocmPseudoOpNamesTbl +
     360                    sizeof(rocmPseudoOpNamesTbl)/sizeof(char*), firstName.c_str()+1,
     361                   CStringLess()) - rocmPseudoOpNamesTbl;
     362   
     363    switch(pseudoOp)
     364    {
     365        case ROCMOP_CALL_CONVENTION:
     366            break;
     367        case ROCMOP_CODEVERSION:
     368            break;
     369        case ROCMOP_CONFIG:
     370            break;
     371        case ROCMOP_CONTROL_DIRECTIVE:
     372            break;
     373        case ROCMOP_DEBUG_PRIVATE_SEGMENT_BUFFER_SGPR:
     374            break;
     375        case ROCMOP_DEBUG_WAVEFRONT_PRIVATE_SEGMENT_OFFSET_SGPR:
     376            break;
     377        case ROCMOP_DEBUGMODE:
     378            break;
     379        case ROCMOP_DIMS:
     380            break;
     381        case ROCMOP_DX10CLAMP:
     382            break;
     383        case ROCMOP_EXCEPTIONS:
     384            break;
     385        case ROCMOP_FLOATMODE:
     386            break;
     387        case ROCMOP_GDS_SEGMENT_SIZE:
     388            break;
     389        case ROCMOP_GROUP_SEGMENT_ALIGN:
     390            break;
     391        case ROCMOP_IEEEMODE:
     392            break;
     393        case ROCMOP_KCODE:
     394            break;
     395        case ROCMOP_KCODEEND:
     396            break;
     397        case ROCMOP_KERNARG_SEGMENT_ALIGN:
     398            break;
     399        case ROCMOP_KERNARG_SEGMENT_SIZE:
     400            break;
     401        case ROCMOP_KERNEL_CODE_ENTRY_OFFSET:
     402            break;
     403        case ROCMOP_KERNEL_CODE_PREFETCH_OFFSET:
     404            break;
     405        case ROCMOP_KERNEL_CODE_PREFETCH_SIZE:
     406            break;
     407        case ROCMOP_LOCALSIZE:
     408            break;
     409        case ROCMOP_MACHINE:
     410            break;
     411        case ROCMOP_MAX_SCRATCH_BACKING_MEMORY:
     412            break;
     413        case ROCMOP_PGMRSRC1:
     414            break;
     415        case ROCMOP_PGMRSRC2:
     416            break;
     417        case ROCMOP_PRIORITY:
     418            break;
     419        case ROCMOP_PRIVATE_SEGMENT_ALIGN:
     420            break;
     421        case ROCMOP_PRIVMODE:
     422            break;
     423        case ROCMOP_RESERVED_SGPR_COUNT:
     424            break;
     425        case ROCMOP_RESERVED_SGPR_FIRST:
     426            break;
     427        case ROCMOP_RESERVED_VGPR_COUNT:
     428            break;
     429        case ROCMOP_RESERVED_VGPR_FIRST:
     430            break;
     431        case ROCMOP_RUNTIME_LOADER_KERNEL_SYMBOL:
     432            break;
     433        case ROCMOP_SCRATCHBUFFER:
     434            break;
     435        case ROCMOP_SGPRSNUM:
     436            break;
     437        case ROCMOP_TGSIZE:
     438            break;
     439        case ROCMOP_USE_DEBUG_ENABLED:
     440            break;
     441        case ROCMOP_USE_DISPATCH_ID:
     442            break;
     443        case ROCMOP_USE_DISPATCH_PTR:
     444            break;
     445        case ROCMOP_USE_DYNAMIC_CALL_STACK:
     446            break;
     447        case ROCMOP_USE_FLAT_SCRATCH_INIT:
     448            break;
     449        case ROCMOP_USE_GRID_WORKGROUP_COUNT:
     450            break;
     451        case ROCMOP_USE_KERNARG_SEGMENT_PTR:
     452            break;
     453        case ROCMOP_USE_ORDERED_APPEND_GDS:
     454            break;
     455        case ROCMOP_USE_PRIVATE_SEGMENT_SIZE:
     456            break;
     457        case ROCMOP_USE_PTR64:
     458            break;
     459        case ROCMOP_USE_QUEUE_PTR:
     460            break;
     461        case ROCMOP_USE_PRIVATE_SEGMENT_BUFFER:
     462            break;
     463        case ROCMOP_USE_XNACK_ENABLED:
     464            break;
     465        case ROCMOP_USERDATANUM:
     466            break;
     467        case ROCMOP_VGPRSNUM:
     468            break;
     469        case ROCMOP_WAVEFRONT_SGPR_COUNT:
     470            break;
     471        case ROCMOP_WAVEFRONT_SIZE:
     472            break;
     473        case ROCMOP_WORKITEM_VGPR_COUNT:
     474            break;
     475        case ROCMOP_WORKGROUP_FBARRIER_COUNT:
     476            break;
     477        case ROCMOP_WORKGROUP_GROUP_SEGMENT_SIZE:
     478            break;
     479        case ROCMOP_WORKITEM_PRIVATE_SEGMENT_SIZE:
     480            break;
     481        default:
     482            return false;
     483    }
     484    return true;
     485}
     486
    290487bool AsmROCmHandler::prepareBinary()
    291488{
  • CLRadeonExtender/trunk/amdasm/DisasmROCm.cpp

    r2560 r2586  
    265265    if ((sgprFlags&64) != 0)
    266266        output.write("        .use_private_segment_size\n", 34);
    267     if ((sgprFlags&128) != 0)
    268         output.write("        .use_grid_workgroup_count_x\n", 36);
    269     if ((sgprFlags&256) != 0)
    270         output.write("        .use_grid_workgroup_count_y\n", 36);
    271     if ((sgprFlags&512) != 0)
    272         output.write("        .use_grid_workgroup_count_z\n", 36);
     267   
     268    if ((sgprFlags&(7U<<7)) != 0)
     269    {
     270        strcpy(buf, "        .use_grid_workgroup_count ");
     271        bufSize = 34;
     272        if ((sgprFlags&128) != 0)
     273            buf[bufSize++] = 'x';
     274        if ((sgprFlags&256) != 0)
     275            buf[bufSize++] = 'y';
     276        if ((sgprFlags&512) != 0)
     277            buf[bufSize++] = 'z';
     278        buf[bufSize++] = '\n';
     279        output.write(buf, bufSize);
     280    }
     281   
    273282    const uint16_t featureFlags = enableFeatureFlags;
    274283    if ((featureFlags&1) != 0)
Note: See TracChangeset for help on using the changeset viewer.