Home | History | Annotate | Line # | Download | only in perf
      1 /*
      2  * Copyright  2018 Intel Corporation
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     21  * IN THE SOFTWARE.
     22  */
     23 
     24 #ifndef INTEL_PERF_MDAPI_H
     25 #define INTEL_PERF_MDAPI_H
     26 
     27 #include <stdint.h>
     28 
     29 #include "dev/intel_device_info.h"
     30 
     31 struct intel_perf_query_result;
     32 
     33 /* Guid has to matches with MDAPI's. */
     34 #define INTEL_PERF_QUERY_GUID_MDAPI "2f01b241-7014-42a7-9eb6-a925cad3daba"
     35 
     36 /*
     37  * Data format expected by MDAPI.
     38  */
     39 
     40 struct gfx7_mdapi_metrics {
     41    uint64_t TotalTime;
     42 
     43    uint64_t ACounters[45];
     44    uint64_t NOACounters[16];
     45 
     46    uint64_t PerfCounter1;
     47    uint64_t PerfCounter2;
     48    uint32_t SplitOccured;
     49    uint32_t CoreFrequencyChanged;
     50    uint64_t CoreFrequency;
     51    uint32_t ReportId;
     52    uint32_t ReportsCount;
     53 };
     54 
     55 #define GTDI_QUERY_BDW_METRICS_OA_COUNT         36
     56 #define GTDI_QUERY_BDW_METRICS_OA_40b_COUNT     32
     57 #define GTDI_QUERY_BDW_METRICS_NOA_COUNT        16
     58 struct gfx8_mdapi_metrics {
     59    uint64_t TotalTime;
     60    uint64_t GPUTicks;
     61    uint64_t OaCntr[GTDI_QUERY_BDW_METRICS_OA_COUNT];
     62    uint64_t NoaCntr[GTDI_QUERY_BDW_METRICS_NOA_COUNT];
     63    uint64_t BeginTimestamp;
     64    uint64_t Reserved1;
     65    uint64_t Reserved2;
     66    uint32_t Reserved3;
     67    uint32_t OverrunOccured;
     68    uint64_t MarkerUser;
     69    uint64_t MarkerDriver;
     70 
     71    uint64_t SliceFrequency;
     72    uint64_t UnsliceFrequency;
     73    uint64_t PerfCounter1;
     74    uint64_t PerfCounter2;
     75    uint32_t SplitOccured;
     76    uint32_t CoreFrequencyChanged;
     77    uint64_t CoreFrequency;
     78    uint32_t ReportId;
     79    uint32_t ReportsCount;
     80 };
     81 
     82 #define GTDI_MAX_READ_REGS 16
     83 
     84 struct gfx9_mdapi_metrics {
     85    uint64_t TotalTime;
     86    uint64_t GPUTicks;
     87    uint64_t OaCntr[GTDI_QUERY_BDW_METRICS_OA_COUNT];
     88    uint64_t NoaCntr[GTDI_QUERY_BDW_METRICS_NOA_COUNT];
     89    uint64_t BeginTimestamp;
     90    uint64_t Reserved1;
     91    uint64_t Reserved2;
     92    uint32_t Reserved3;
     93    uint32_t OverrunOccured;
     94    uint64_t MarkerUser;
     95    uint64_t MarkerDriver;
     96 
     97    uint64_t SliceFrequency;
     98    uint64_t UnsliceFrequency;
     99    uint64_t PerfCounter1;
    100    uint64_t PerfCounter2;
    101    uint32_t SplitOccured;
    102    uint32_t CoreFrequencyChanged;
    103    uint64_t CoreFrequency;
    104    uint32_t ReportId;
    105    uint32_t ReportsCount;
    106 
    107    uint64_t UserCntr[GTDI_MAX_READ_REGS];
    108    uint32_t UserCntrCfgId;
    109    uint32_t Reserved4;
    110 };
    111 
    112 /* Add new definition */
    113 #define gfx11_mdapi_metrics gfx9_mdapi_metrics
    114 
    115 struct mdapi_pipeline_metrics {
    116    uint64_t IAVertices;
    117    uint64_t IAPrimitives;
    118    uint64_t VSInvocations;
    119    uint64_t GSInvocations;
    120    uint64_t GSPrimitives;
    121    uint64_t CInvocations;
    122    uint64_t CPrimitives;
    123    uint64_t PSInvocations;
    124    uint64_t HSInvocations;
    125    uint64_t DSInvocations;
    126    uint64_t CSInvocations;
    127    uint64_t Reserved1; /* Gfx10+ */
    128 };
    129 
    130 int intel_perf_query_result_write_mdapi(void *data, uint32_t data_size,
    131                                         const struct intel_device_info *devinfo,
    132                                         const struct intel_perf_query_info *query,
    133                                         const struct intel_perf_query_result *result);
    134 
    135 static inline void intel_perf_query_mdapi_write_marker(void *data, uint32_t data_size,
    136                                                        const struct intel_device_info *devinfo,
    137                                                        uint64_t value)
    138 {
    139    switch (devinfo->ver) {
    140    case 8: {
    141       if (data_size < sizeof(struct gfx8_mdapi_metrics))
    142          return;
    143       struct gfx8_mdapi_metrics *mdapi_data = data;
    144       mdapi_data->MarkerUser = value;
    145       break;
    146    }
    147    case 9:
    148    case 11: {
    149       if (data_size < sizeof(struct gfx9_mdapi_metrics))
    150          return;
    151       struct gfx9_mdapi_metrics *mdapi_data = data;
    152       mdapi_data->MarkerUser = value;
    153       break;
    154    }
    155    default:
    156       break;
    157    }
    158 }
    159 
    160 #endif /* INTEL_PERF_MDAPI_H */
    161