Media scalability tooling
Subsystems (2)
cover Media scalability tooling
From: Tvrtko Ursulin <[email protected]>
A bunch of patches to trace.pl and gem_wsim which enable simulation and load balancing analysis of the Virtual Engine work done separately by Chris Wilson.
Culmination is being able to simulate a so called frame split media workloads.
Example workload for this looks like this (annotated only for cover letter):
X.1.0 ; disable preemption on context 1
M.1.VCS1 ; configure engine map on context 1
B.1 ; turn on load balancing on context 1
X.2.0 ; \
M.2.VCS2 ; -> same as above but for context 2
B.2 ; /
b.2.1.VCS1 ; bond VCS2 in context 2 with VCS1
f ; create an unsignaled fence
1.DEFAULT.*.f-1.0 ; submit an infinite batch to ctx 1, with input fence
2.DEFAULT.4000-6000.s-1.0 ; submit a 4-6ms batch to ctx 2, with submit fence from the previous step
a.-3 ; advance the fence created 3 lines above s.-2 ; wait for ctx 2 batch to complete T.-4 ; terminate ctx 1 infinite batch
3.RCS.2000-4000.-5/-4.0 ; submit 2-4ms ctx 3 batch to RCS, with data dependencies
3.VECS.2000.-1.0 ; submit 2ms ctx 3 batch to VECS, data dependency on previous batch
4.BCS.1000.-1.0 ; submit 1ms ctx 4 batch to BCS, data dependency on previous batch
s.-2 ; wait for ctx 3 batch to complete
p.16667 ; start next iteration to hit 60fps simulation
And can be run for instance like this:
./gem_wsim -n <calibration> -w wsim/frame_split_60fps.wsim -r 60 -c 3
This runs three clients of the same workload, 60 iterations each.
This can then also be captured with trace.pl and a HTML representation of the execution timeline analysed:
../scripts/trace.pl --trace ./gem_wsim ...
perf script | ../scripts/trace.pl -s -c --gpu-timeline --html >timeline.html
[Vis npm module is required to be present in the same directory as the HTML ]
[file, see trace.pl --help for instructions. ]
Tvrtko Ursulin (17):
lib: Update uapi headers
trace.pl: Virtual engine support
trace.pl: Virtual engine preemption support wsim/media-bench: i915 balancing
gem_wsim: Use IGT uapi headers
gem_wsim: Fix shadowed local
gem_wsim: Factor out common error handling
gem_wsim: More wsim_err
gem_wsim: Submit fence support
gem_wsim: Extract str to engine lookup
gem_wsim: Engine map support
gem_wsim: Save some lines by changing to implicit NULL checking
gem_wsim: Compact int command parsing with a macro
gem_wsim: Engine map load balance command
gem_wsim: Engine bond command
gem_wsim: Some more example workloads
gem_wsim: Infinite batch support
benchmarks/gem_wsim.c | 1060 +++++++++++++------ benchmarks/wsim/README | 111 +- benchmarks/wsim/frame-split-60fps.wsim | 18 + benchmarks/wsim/high-composited-game.wsim | 11 + benchmarks/wsim/media-1080p-player.wsim | 5 + benchmarks/wsim/medium-composited-game.wsim | 9 + include/drm-uapi/amdgpu_drm.h | 52 +- include/drm-uapi/drm.h | 16 + include/drm-uapi/drm_fourcc.h | 224 ++++ include/drm-uapi/drm_mode.h | 26 +- include/drm-uapi/etnaviv_drm.h | 6 + include/drm-uapi/exynos_drm.h | 240 +++++ include/drm-uapi/i915_drm.h | 239 ++++- include/drm-uapi/msm_drm.h | 2 + include/drm-uapi/sync_file.h | 98 -- include/drm-uapi/tegra_drm.h | 492 ++++++++- include/drm-uapi/v3d_drm.h | 194 ++++ include/drm-uapi/vc4_drm.h | 13 +- include/drm-uapi/virtgpu_drm.h | 1 + include/drm-uapi/vmwgfx_drm.h | 166 ++- scripts/media-bench.pl | 9 +- scripts/trace.pl | 244 ++++- 22 files changed, 2705 insertions(+), 531 deletions(-) create mode 100644 benchmarks/wsim/frame-split-60fps.wsim create mode 100644 benchmarks/wsim/high-composited-game.wsim create mode 100644 benchmarks/wsim/media-1080p-player.wsim create mode 100644 benchmarks/wsim/medium-composited-game.wsim delete mode 100644 include/drm-uapi/sync_file.h create mode 100644 include/drm-uapi/v3d_drm.h
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/17 lib: Update uapi headers
From: Tvrtko Ursulin <[email protected]>
Sync with latest DRM uapi changes.
--- include/drm-uapi/amdgpu_drm.h | 52 +++- include/drm-uapi/drm.h | 16 ++ include/drm-uapi/drm_fourcc.h | 224 +++++++++++++++ include/drm-uapi/drm_mode.h | 26 +- include/drm-uapi/etnaviv_drm.h | 6 + include/drm-uapi/exynos_drm.h | 240 ++++++++++++++++ include/drm-uapi/i915_drm.h | 239 +++++++++++++++- include/drm-uapi/msm_drm.h | 2 + include/drm-uapi/sync_file.h | 98 ------- include/drm-uapi/tegra_drm.h | 492 ++++++++++++++++++++++++++++++++- include/drm-uapi/v3d_drm.h | 194 +++++++++++++ include/drm-uapi/vc4_drm.h | 13 +- include/drm-uapi/virtgpu_drm.h | 1 + include/drm-uapi/vmwgfx_drm.h | 166 ++++++++--- 14 files changed, 1613 insertions(+), 156 deletions(-) delete mode 100644 include/drm-uapi/sync_file.h create mode 100644 include/drm-uapi/v3d_drm.h
include/drm-uapi/amdgpu_drm.h +51 -1
@@ -72,12 +72,41 @@ extern "C" {#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched) +/** +* DOC: memory domains +* +* %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible. +* Memory in this pool could be swapped out to disk if there is pressure. +* +* %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the +* GPU's virtual address space via gart. Gart memory linearizes non-contiguous +* pages of system memory, allows GPU access system memory in a linezrized +* fashion. +* +* %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory +* carved out by the BIOS. +* +* %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data +* across shader threads. +* +* %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the +* execution of all the waves on a device. +* +* %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines +* for appending data. +*/ #define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2#define AMDGPU_GEM_DOMAIN_VRAM 0x4#define AMDGPU_GEM_DOMAIN_GDS 0x8#define AMDGPU_GEM_DOMAIN_GWS 0x10#define AMDGPU_GEM_DOMAIN_OA 0x20 +#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \ + AMDGPU_GEM_DOMAIN_GTT | \ + AMDGPU_GEM_DOMAIN_VRAM | \ + AMDGPU_GEM_DOMAIN_GDS | \ + AMDGPU_GEM_DOMAIN_GWS | \ + AMDGPU_GEM_DOMAIN_OA)/* Flag that CPU access will be required for the case of VRAM domain */ #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
@@ -95,6 +124,10 @@ extern "C" {#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)/* Flag that BO sharing will be explicitly synchronized */ #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7) +/* Flag that indicates allocating MQD gart on GFX9, where the mtype +* for the second page onward should be set to NC. +*/ +#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8)struct drm_amdgpu_gem_create_in {/** the requested memory size */
@@ -473,7 +506,8 @@ struct drm_amdgpu_gem_va {#define AMDGPU_HW_IP_UVD_ENC 5#define AMDGPU_HW_IP_VCN_DEC 6#define AMDGPU_HW_IP_VCN_ENC 7 -#define AMDGPU_HW_IP_NUM 8 +#define AMDGPU_HW_IP_VCN_JPEG 8 +#define AMDGPU_HW_IP_NUM 9#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
@@ -482,6 +516,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06struct drm_amdgpu_cs_chunk {__u32 chunk_id;
@@ -520,6 +555,10 @@ union drm_amdgpu_cs {/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */ #define AMDGPU_IB_FLAG_PREEMPT (1<<2) +/* The IB fence should do the L2 writeback but not invalidate any shader +* caches (L2/vL1/sL1/I$). */ +#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3) +struct drm_amdgpu_cs_chunk_ib {__u32 _pad;/** AMDGPU_IB_FLAG_* */
@@ -618,6 +657,16 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_FW_SOS 0x0c/* Subquery id: Query PSP ASD firmware version */ #define AMDGPU_INFO_FW_ASD 0x0d +/* Subquery id: Query VCN firmware version */ +#define AMDGPU_INFO_FW_VCN 0x0e +/* Subquery id: Query GFX RLC SRLC firmware version */ +#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f +/* Subquery id: Query GFX RLC SRLG firmware version */ +#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10 +/* Subquery id: Query GFX RLC SRLS firmware version */ +#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11 +/* Subquery id: Query DMCU firmware version */ +#define AMDGPU_INFO_FW_DMCU 0x12/* number of bytes moved for TTM migration */ #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f/* the used VRAM size */
@@ -806,6 +855,7 @@ struct drm_amdgpu_info_firmware {#define AMDGPU_VRAM_TYPE_GDDR5 5#define AMDGPU_VRAM_TYPE_HBM 6#define AMDGPU_VRAM_TYPE_DDR3 7 +#define AMDGPU_VRAM_TYPE_DDR4 8struct drm_amdgpu_info_device {/** PCI Device ID */
include/drm-uapi/drm.h +16 -0
@@ -674,6 +674,22 @@ struct drm_get_cap {*/ #define DRM_CLIENT_CAP_ATOMIC 3 +/** +* DRM_CLIENT_CAP_ASPECT_RATIO +* +* If set to 1, the DRM core will provide aspect ratio information in modes. +*/ +#define DRM_CLIENT_CAP_ASPECT_RATIO 4 + +/** +* DRM_CLIENT_CAP_WRITEBACK_CONNECTORS +* +* If set to 1, the DRM core will expose special connectors to be used for +* writing back to memory the scene setup in the commit. Depends on client +* also supporting DRM_CLIENT_CAP_ATOMIC +*/ +#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5 +/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap {__u64 capability;
include/drm-uapi/drm_fourcc.h +224 -0
259 lines not on this page · raw message
include/drm-uapi/drm_mode.h +22 -4
@@ -93,6 +93,15 @@ extern "C" {#define DRM_MODE_PICTURE_ASPECT_NONE 0#define DRM_MODE_PICTURE_ASPECT_4_3 1#define DRM_MODE_PICTURE_ASPECT_16_9 2 +#define DRM_MODE_PICTURE_ASPECT_64_27 3 +#define DRM_MODE_PICTURE_ASPECT_256_135 4 + +/* Content type options */ +#define DRM_MODE_CONTENT_TYPE_NO_DATA 0 +#define DRM_MODE_CONTENT_TYPE_GRAPHICS 1 +#define DRM_MODE_CONTENT_TYPE_PHOTO 2 +#define DRM_MODE_CONTENT_TYPE_CINEMA 3 +#define DRM_MODE_CONTENT_TYPE_GAME 4/* Aspect ratio flag bitmask (4 bits 22:19) */ #define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
@@ -102,6 +111,10 @@ extern "C" { (DRM_MODE_PICTURE_ASPECT_4_3<<19)#define DRM_MODE_FLAG_PIC_AR_16_9 \ (DRM_MODE_PICTURE_ASPECT_16_9<<19) +#define DRM_MODE_FLAG_PIC_AR_64_27 \ + (DRM_MODE_PICTURE_ASPECT_64_27<<19) +#define DRM_MODE_FLAG_PIC_AR_256_135 \ + (DRM_MODE_PICTURE_ASPECT_256_135<<19)#define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \ DRM_MODE_FLAG_NHSYNC | \
@@ -173,8 +186,9 @@ extern "C" {/* * DRM_MODE_REFLECT_<axis> * -* Signals that the contents of a drm plane is reflected in the <axis> axis, +* Signals that the contents of a drm plane is reflected along the <axis> axis, * in the same way as mirroring. +* See kerneldoc chapter "Plane Composition Properties" for more details. * * This define is provided as a convenience, looking up the property id * using the name->prop id lookup is the preferred method.
@@ -338,6 +352,7 @@ enum drm_mode_subconnector {#define DRM_MODE_CONNECTOR_VIRTUAL 15#define DRM_MODE_CONNECTOR_DSI 16#define DRM_MODE_CONNECTOR_DPI 17 +#define DRM_MODE_CONNECTOR_WRITEBACK 18struct drm_mode_get_connector {
@@ -363,7 +378,7 @@ struct drm_mode_get_connector {__u32 pad; }; -#define DRM_MODE_PROP_PENDING (1<<0) +#define DRM_MODE_PROP_PENDING (1<<0)/* deprecated, do not use */ #define DRM_MODE_PROP_RANGE (1<<1)#define DRM_MODE_PROP_IMMUTABLE (1<<2)#define DRM_MODE_PROP_ENUM (1<<3)/* enumerated type with text strings */
@@ -598,8 +613,11 @@ struct drm_mode_crtc_lut { };struct drm_color_ctm { -/* Conversion matrix in S31.32 format. */ -__s64 matrix[9 ]; +/* +* Conversion matrix in S31.32 sign-magnitude +* (not two's complement!) format. +*/ +__u64 matrix[9 ]; };struct drm_color_lut {
include/drm-uapi/etnaviv_drm.h +6 -0
@@ -55,6 +55,12 @@ struct drm_etnaviv_timespec {#define ETNAVIV_PARAM_GPU_FEATURES_4 0x07#define ETNAVIV_PARAM_GPU_FEATURES_5 0x08#define ETNAVIV_PARAM_GPU_FEATURES_6 0x09 +#define ETNAVIV_PARAM_GPU_FEATURES_7 0x0a +#define ETNAVIV_PARAM_GPU_FEATURES_8 0x0b +#define ETNAVIV_PARAM_GPU_FEATURES_9 0x0c +#define ETNAVIV_PARAM_GPU_FEATURES_10 0x0d +#define ETNAVIV_PARAM_GPU_FEATURES_11 0x0e +#define ETNAVIV_PARAM_GPU_FEATURES_12 0x0f#define ETNAVIV_PARAM_GPU_STREAM_COUNT 0x10#define ETNAVIV_PARAM_GPU_REGISTER_MAX 0x11
include/drm-uapi/exynos_drm.h +240 -0
266 lines not on this page · raw message
include/drm-uapi/i915_drm.h +237 -2
302 lines not on this page · raw message
include/drm-uapi/msm_drm.h +2 -0
@@ -201,10 +201,12 @@ struct drm_msm_gem_submit_bo {#define MSM_SUBMIT_NO_IMPLICIT 0x80000000/* disable implicit sync */ #define MSM_SUBMIT_FENCE_FD_IN 0x40000000/* enable input fence_fd */ #define MSM_SUBMIT_FENCE_FD_OUT 0x20000000/* enable output fence_fd */ +#define MSM_SUBMIT_SUDO 0x10000000/* run submitted cmds from RB */ #define MSM_SUBMIT_FLAGS ( \ MSM_SUBMIT_NO_IMPLICIT | \ MSM_SUBMIT_FENCE_FD_IN | \ MSM_SUBMIT_FENCE_FD_OUT | \ + MSM_SUBMIT_SUDO | \ 0)/* Each cmdstream submit consists of a table of buffers involved, and
include/drm-uapi/sync_file.h deleted +0 -98
98 lines not on this page · raw message
include/drm-uapi/tegra_drm.h +482 -10
632 lines not on this page · raw message
include/drm-uapi/v3d_drm.h new file +194 -0
194 lines not on this page · raw message
include/drm-uapi/vc4_drm.h +10 -3
@@ -183,10 +183,17 @@ struct drm_vc4_submit_cl {/* ID of the perfmon to attach to this job. 0 means no perfmon. */ __u32 perfmonid; -/* Unused field to align this struct on 64 bits. Must be set to 0. -* If one ever needs to add an u32 field to this struct, this field -* can be used. +/* Syncobj handle to wait on. If set, processing of this render job +* will not start until the syncobj is signaled. 0 means ignore. */ +__u32 in_sync; + +/* Syncobj handle to export fence to. If set, the fence in the syncobj +* will be replaced with a fence that signals upon completion of this +* render job. 0 means ignore. +*/ +__u32 out_sync; +__u32 pad2; };
include/drm-uapi/virtgpu_drm.h +1 -0
@@ -63,6 +63,7 @@ struct drm_virtgpu_execbuffer { };#define VIRTGPU_PARAM_3D_FEATURES 1/* do we have 3D features in the hw */ +#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2/* do we have the capset fix */ struct drm_virtgpu_getparam {__u64 param;
include/drm-uapi/vmwgfx_drm.h +128 -38
254 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/17 trace.pl: Virtual engine support
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Add virtual/queue timelines to both stdout and HTML output.
A new timeline is created for each queue/virtual engine to display associated requests in queued and runnable states. Once requests are submitted to a real engine for executing they show up on the physical engine timeline.
--- scripts/trace.pl | 230 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 200 insertions(+), 30 deletions(-)
scripts/trace.pl +200 -30
@@ -27,10 +27,15 @@ use warnings; use 5.010; my $gid = 0; -my (%db, %queue, %submit, %notify, %rings, %ctxdb, %ringmap, %reqwait, %ctxtimelines); +my (%db, %vdb, %queue, %submit, %notify, %rings, %ctxdb, %ringmap, %reqwait, %ctxtimelines); +my (%cids, %ctxmap); +my $cid = 0; +my %queues; my @freqs; -my $max_items = 3000; +use constant VENG => '255:0'; + +my $max_requests = 1000; my $width_us = 32000; my $correct_durations = 0; my %ignore_ring;
@@ -180,21 +185,21 @@ sub arg_trace return @_; } -sub arg_max_items +sub arg_max_requests { my $val; return unless scalar(@_); - if ($_[0] eq '--max-items' or $_[0] eq '-m') { + if ($_[0] eq '--max-requests' or $_[0] eq '-m') { shift @_; $val = shift @_; - } elsif ($_[0] =~ /--max-items=(\d+)/) { + } elsif ($_[0] =~ /--max-requests=(\d+)/) { shift @_; $val = $1; } - $max_items = int($val) if defined $val; + $max_requests = int($val) if defined $val; return @_; }
@@ -291,7 +296,7 @@ while (@args) { @args = arg_avg_delay_stats(@args); @args = arg_gpu_timeline(@args); @args = arg_trace(@args); - @args = arg_max_items(@args); + @args = arg_max_requests(@args); @args = arg_zoom_width(@args); @args = arg_split_requests(@args); @args = arg_ignore_ring(@args);
@@ -380,6 +385,7 @@ while (<>) { my %rw; next if exists $reqwait{$key}; + die if $ring eq VENG and not exists $queues{$ctx}; $rw{'key'} = $key; $rw{'ring'} = $ring;
@@ -388,9 +394,19 @@ while (<>) { $rw{'start'} = $time; $reqwait{$key} = \%rw; } elsif ($tp_name eq 'i915:i915_request_wait_end:') { - next unless exists $reqwait{$key}; + die if $ring eq VENG and not exists $queues{$ctx}; + + if (exists $reqwait{$key}) { + $reqwait{$key}->{'end'} = $time; + } else { # Virtual engine + my $vkey = db_key(VENG, $ctx, $seqno); + + die unless exists $reqwait{$vkey}; - $reqwait{$key}->{'end'} = $time; + # If the wait started on the virtual engine, attribute + # it to it completely. + $reqwait{$vkey}->{'end'} = $time; + } } elsif ($tp_name eq 'i915:i915_request_add:') { if (exists $queue{$key}) { $ctxdb{$orig_ctx}++;
@@ -401,19 +417,52 @@ while (<>) { } $queue{$key} = $time; + if ($ring eq VENG and not exists $queues{$ctx}) { + $queues{$ctx} = 1 ; + $cids{$ctx} = $cid++; + $ctxmap{$cids{$ctx}} = $ctx; + } } elsif ($tp_name eq 'i915:i915_request_submit:') { die if exists $submit{$key}; die unless exists $queue{$key}; + die if $ring eq VENG and not exists $queues{$ctx}; $submit{$key} = $time; } elsif ($tp_name eq 'i915:i915_request_in:') { + my ($q, $s); my %req; # preemption delete $db{$key} if exists $db{$key}; - die unless exists $queue{$key}; - die unless exists $submit{$key}; + unless (exists $queue{$key}) { + # Virtual engine + my $vkey = db_key(VENG, $ctx, $seqno); + my %req; + + die unless exists $queues{$ctx}; + die unless exists $queue{$vkey}; + die unless exists $submit{$vkey}; + + # Create separate request record on the queue timeline + $q = $queue{$vkey}; + $s = $submit{$vkey}; + $req{'queue'} = $q; + $req{'submit'} = $s; + $req{'start'} = $time; + $req{'end'} = $time; + $req{'ring'} = VENG; + $req{'seqno'} = $seqno; + $req{'ctx'} = $ctx; + $req{'name'} = $ctx . '/' . $seqno; + $req{'global'} = $tp{'global'}; + $req{'port'} = $tp{'port'}; + + $vdb{$vkey} = \%req; + } else { + $q = $queue{$key}; + $s = $submit{$key}; + } $req{'start'} = $time; $req{'ring'} = $ring;
@@ -423,8 +472,9 @@ while (<>) { $req{'name'} = $ctx . '/' . $seqno; $req{'global'} = $tp{'global'}; $req{'port'} = $tp{'port'}; - $req{'queue'} = $queue{$key}; - $req{'submit'} = $submit{$key}; + $req{'queue'} = $q; + $req{'submit'} = $s; + $req{'virtual'} = 1 if exists $queues{$ctx}; $rings{$ring} = $gid++ unless exists $rings{$ring}; $ringmap{$rings{$ring}} = $ring; $db{$key} = \%req;
@@ -720,8 +770,10 @@ foreach my $key (@sorted_keys) { $running{$ring} += $end - $start if $correct_durations or not exists $db{$key}->{'no-end'}; - $runnable{$ring} += $db{$key}->{'execute-delay'}; - $queued{$ring} += $start - $db{$key}->{'execute-delay'} - $db{$key}->{'queue'}; + unless (exists $db{$key}->{'virtual'}) { + $runnable{$ring} += $db{$key}->{'execute-delay'}; + $queued{$ring} += $start - $db{$key}->{'execute-delay'} - $db{$key}->{'queue'}; + } $batch_count{$ring}++;
@@ -840,6 +892,12 @@ foreach my $key (keys %reqwait) { $reqw{$reqwait{$key}->{'ring'}} += $reqwait{$key}->{'end'} - $reqwait{$key}->{'start'}; } +# Add up all request waits per virtual engine +my %vreqw; +foreach my $key (keys %reqwait) { + $vreqw{$reqwait{$key}->{'ctx'}} += $reqwait{$key}->{'end'} - $reqwait{$key}->{'start'}; +} + say sprintf('GPU: %.2f%% idle, %.2f%% busy', $flat_busy{'gpu-idle'}, $flat_busy{'gpu-busy'}) unless $html;
@@ -961,18 +1019,24 @@ ENDHTML sub html_stats { my ($stats, $group, $id) = @_; + my $veng = exists $stats->{'virtual'} ? 1 : 0; my $name; - $name = 'Ring' . $group; + $name = $veng ? 'Virtual' : 'Ring'; + $name .= $group; $name .= '<br><small><br>'; - $name .= sprintf('%.2f', $stats->{'idle'}) . '% idle<br><br>'; - $name .= sprintf('%.2f', $stats->{'busy'}) . '% busy<br>'; + unless ($veng) { + $name .= sprintf('%.2f', $stats->{'idle'}) . '% idle<br><br>'; + $name .= sprintf('%.2f', $stats->{'busy'}) . '% busy<br>'; + } $name .= sprintf('%.2f', $stats->{'runnable'}) . '% runnable<br>'; $name .= sprintf('%.2f', $stats->{'queued'}) . '% queued<br><br>'; $name .= sprintf('%.2f', $stats->{'wait'}) . '% wait<br><br>'; $name .= $stats->{'count'} . ' batches<br>'; - $name .= sprintf('%.2f', $stats->{'avg'}) . 'us avg batch<br>'; - $name .= sprintf('%.2f', $stats->{'total-avg'}) . 'us avg engine batch<br>'; + unless ($veng) { + $name .= sprintf('%.2f', $stats->{'avg'}) . 'us avg batch<br>'; + $name .= sprintf('%.2f', $stats->{'total-avg'}) . 'us avg engine batch<br>'; + } $name .= '</small>'; print "\t{id: $id, content: '$name'},\n";
@@ -981,17 +1045,24 @@ sub html_stats sub stdio_stats { my ($stats, $group, $id) = @_; + my $veng = exists $stats->{'virtual'} ? 1 : 0; my $str; - $str = 'Ring' . $group . ': '; + $str = $veng ? 'Virtual' : 'Ring'; + $str .= $group . ': '; $str .= $stats->{'count'} . ' batches, '; - $str .= sprintf('%.2f (%.2f) avg batch us, ', $stats->{'avg'}, $stats->{'total-avg'}); - $str .= sprintf('%.2f', $stats->{'idle'}) . '% idle, '; - $str .= sprintf('%.2f', $stats->{'busy'}) . '% busy, '; + unless ($veng) { + $str .= sprintf('%.2f (%.2f) avg batch us, ', + $stats->{'avg'}, $stats->{'total-avg'}); + $str .= sprintf('%.2f', $stats->{'idle'}) . '% idle, '; + $str .= sprintf('%.2f', $stats->{'busy'}) . '% busy, '; + } + $str .= sprintf('%.2f', $stats->{'runnable'}) . '% runnable, '; $str .= sprintf('%.2f', $stats->{'queued'}) . '% queued, '; $str .= sprintf('%.2f', $stats->{'wait'}) . '% wait'; - if ($avg_delay_stats) { + + if ($avg_delay_stats and not $veng) { $str .= ', submit/execute/save-avg=('; $str .= sprintf('%.2f/%.2f/%.2f)', $stats->{'submit'}, $stats->{'execute'}, $stats->{'save'}); }
@@ -1013,8 +1084,16 @@ foreach my $group (sort keys %rings) { $stats{'idle'} = (1.0 - $flat_busy{$ring} / $elapsed) * 100.0; $stats{'busy'} = $running{$ring} / $elapsed * 100.0; - $stats{'runnable'} = $runnable{$ring} / $elapsed * 100.0; - $stats{'queued'} = $queued{$ring} / $elapsed * 100.0; + if (exists $runnable{$ring}) { + $stats{'runnable'} = $runnable{$ring} / $elapsed * 100.0; + } else { + $stats{'runnable'} = 0; + } + if (exists $queued{$ring}) { + $stats{'queued'} = $queued{$ring} / $elapsed * 100.0; + } else { + $stats{'queued'} = 0; + } $reqw{$ring} = 0 unless exists $reqw{$ring}; $stats{'wait'} = $reqw{$ring} / $elapsed * 100.0; $stats{'count'} = $batch_count{$ring};
@@ -1031,6 +1110,59 @@ foreach my $group (sort keys %rings) { } } +sub sortVQueue { + my $as = $vdb{$a}->{'queue'}; + my $bs = $vdb{$b}->{'queue'}; + my $val; + + $val = $as <=> $bs; + $val = $a cmp $b if $val == 0; + + return $val; +} + +my @sorted_vkeys = sort sortVQueue keys %vdb; +my (%vqueued, %vrunnable); + +foreach my $key (@sorted_vkeys) { + my $ctx = $vdb{$key}->{'ctx'}; + + $vdb{$key}->{'submit-delay'} = $vdb{$key}->{'submit'} - $vdb{$key}->{'queue'}; + $vdb{$key}->{'execute-delay'} = $vdb{$key}->{'start'} - $vdb{$key}->{'submit'}; + + $vqueued{$ctx} += $vdb{$key}->{'submit-delay'}; + $vrunnable{$ctx} += $vdb{$key}->{'execute-delay'}; +} + +my $veng_id = $engine_start_id + scalar(keys %rings); + +foreach my $cid (sort keys %ctxmap) { + my $ctx = $ctxmap{$cid}; + my $elapsed = $last_ts - $first_ts; + my %stats; + + $stats{'virtual'} = 1; + if (exists $vrunnable{$ctx}) { + $stats{'runnable'} = $vrunnable{$ctx} / $elapsed * 100.0; + } else { + $stats{'runnable'} = 0; + } + if (exists $vqueued{$ctx}) { + $stats{'queued'} = $vqueued{$ctx} / $elapsed * 100.0; + } else { + $stats{'queued'} = 0; + } + $vreqw{$ctx} = 0 unless exists $vreqw{$ctx}; + $stats{'wait'} = $vreqw{$ctx} / $elapsed * 100.0; + $stats{'count'} = scalar(grep {$ctx == $vdb{$_}->{'ctx'}} keys %vdb); + + if ($html) { + html_stats(\%stats, $cid, $veng_id++); + } else { + stdio_stats(\%stats, $cid, $veng_id++); + } +} + exit 0 unless $html; print <<ENDHTML;
@@ -1134,6 +1266,7 @@ sub box_style } my $i = 0; +my $req = 0; foreach my $key (sort sortQueue keys %db) { my ($name, $ctx, $seqno) = ($db{$key}->{'name'}, $db{$key}->{'ctx'}, $db{$key}->{'seqno'}); my ($queue, $start, $notify, $end) = ($db{$key}->{'queue'}, $db{$key}->{'start'}, $db{$key}->{'notify'}, $db{$key}->{'end'});
@@ -1147,7 +1280,7 @@ foreach my $key (sort sortQueue keys %db) { my $skey; # submit to execute - unless (exists $skip_box{'queue'}) { + unless (exists $skip_box{'queue'} or exists $db{$key}->{'virtual'}) { $skey = 2 * $max_seqno * $ctx + 2 * $seqno; $style = box_style($ctx, 'queue'); $content = "$name<br>$db{$key}->{'submit-delay'}us <small>($db{$key}->{'execute-delay'}us)</small>";
@@ -1158,7 +1291,7 @@ foreach my $key (sort sortQueue keys %db) { # execute to start $engine_start = $db{$key}->{'start'} unless defined $engine_start; - unless (exists $skip_box{'ready'}) { + unless (exists $skip_box{'ready'} or exists $db{$key}->{'virtual'}) { $skey = 2 * $max_seqno * $ctx + 2 * $seqno + 1; $style = box_style($ctx, 'ready'); $content = "<small>$name<br>$db{$key}->{'execute-delay'}us</small>";
@@ -1199,7 +1332,7 @@ foreach my $key (sort sortQueue keys %db) { $last_ts = $end; - last if $i > $max_items; + last if ++$req > $max_requests; } push @freqs, [$prev_freq_ts, $last_ts, $prev_freq] if $prev_freq;
@@ -1232,6 +1365,43 @@ if ($gpu_timeline) { } } +$req = 0; +$veng_id = $engine_start_id + scalar(keys %rings); +foreach my $key (@sorted_vkeys) { + my ($name, $ctx, $seqno) = ($vdb{$key}->{'name'}, $vdb{$key}->{'ctx'}, $vdb{$key}->{'seqno'}); + my $queue = $vdb{$key}->{'queue'}; + my $submit = $vdb{$key}->{'submit'}; + my $engine_start = $db{$key}->{'engine-start'}; + my ($content, $style, $startend, $skey); + my $group = $veng_id + $cids{$ctx}; + my $subgroup = $ctx - $min_ctx; + my $type = ' type: \'range\','; + my $duration; + + # submit to execute + unless (exists $skip_box{'queue'}) { + $skey = 2 * $max_seqno * $ctx + 2 * $seqno; + $style = box_style($ctx, 'queue'); + $content = "$name<br>$vdb{$key}->{'submit-delay'}us <small>($vdb{$key}->{'execute-delay'}us)</small>"; + $startend = 'start: ' . $queue . ', end: ' . $submit; + print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n"; + $i++; + } + + # execute to start + $engine_start = $vdb{$key}->{'start'} unless defined $engine_start; + unless (exists $skip_box{'ready'}) { + $skey = 2 * $max_seqno * $ctx + 2 * $seqno + 1; + $style = box_style($ctx, 'ready'); + $content = "<small>$name<br>$vdb{$key}->{'execute-delay'}us</small>"; + $startend = 'start: ' . $submit . ', end: ' . $engine_start; + print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n"; + $i++; + } + + last if ++$req > $max_requests; +} + my $end_ts = $first_ts + $width_us; $first_ts = $first_ts;
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/17 trace.pl: Virtual engine preemption support
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Use the 'completed?' tracepoint field to detect more robustly when a request has been preempted and remove it from the engine database if so.
Otherwise the script can hit a scenario where the same global seqno will be mentioned multiple times (on an engine seqno) which aborts processing.
--- scripts/trace.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
scripts/trace.pl +9 -5
@@ -481,12 +481,16 @@ while (<>) { } elsif ($tp_name eq 'i915:i915_request_out:') { my $gkey = global_key($ring, $tp{'global'}); - die unless exists $db{$key}; - die unless exists $db{$key}->{'start'}; - die if exists $db{$key}->{'end'}; + if ($tp{'completed?'}) { + die unless exists $db{$key}; + die unless exists $db{$key}->{'start'}; + die if exists $db{$key}->{'end'}; - $db{$key}->{'end'} = $time; - $db{$key}->{'notify'} = $notify{$gkey} if exists $notify{$gkey}; + $db{$key}->{'end'} = $time; + $db{$key}->{'notify'} = $notify{$gkey} if exists $notify{$gkey}; + } else { + delete $db{$key}; + } } elsif ($tp_name eq 'i915:intel_engine_notify:') { my $gkey = global_key($ring, $seqno);
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 4/17 wsim/media-bench: i915 balancing
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Support i915 virtual engine from gem_wsim (-b i915) and media-bench.pl
--- benchmarks/gem_wsim.c | 289 ++++++++++++++++++++++++++++++++++------- scripts/media-bench.pl | 9 +- 2 files changed, 251 insertions(+), 47 deletions(-)
benchmarks/gem_wsim.c +245 -44
@@ -59,6 +59,20 @@#define LOCAL_I915_EXEC_FENCE_IN (1<<16)#define LOCAL_I915_EXEC_FENCE_OUT (1<<17) +struct local_drm_i915_gem_context_create_v2 { +/* output: id of new context*/ +__u32 ctx_id; +__u32 flags; +#define LOCAL_I915_GEM_CONTEXT_SHARE_GTT 0x1 +#define LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE 0x2 +__u32 share_ctx; +__u32 pad; +}; + +#define LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct local_drm_i915_gem_context_create_v2) + +#define LOCAL_I915_CONTEXT_PARAM_ENGINES 0x7 +enum intel_engine_id {RCS ,BCS ,
@@ -143,6 +157,14 @@ struct w_step DECLARE_EWMA(uint64_t, rt, 4, 2) +struct ctx { +uint32_t id; +int priority; +bool targets_instance; +bool wants_balance; +unsigned int static_vcs; +}; +struct workload {unsigned int id;
@@ -164,11 +186,7 @@ struct workloadstruct timespec repeat_start;unsigned int nr_ctxs; -struct { -uint32_t id; -int priority; -unsigned int static_vcs; - } *ctx_list; +struct ctx *ctx_list;int sync_timeline;uint32_t sync_seqno;
@@ -225,6 +243,7 @@ static int fd;#define HEARTBEAT (1<<7)#define GLOBAL_BALANCE (1<<8)#define DEPSYNC (1<<9) +#define I915 (1<<10)#define SEQNO_IDX (engine) ((engine) * 16)#define SEQNO_OFFSET (engine) (SEQNO_IDX(engine) * sizeof(uint32_t))
@@ -836,7 +855,11 @@ eb_set_engine(struct drm_i915_gem_execbuffer2 *eb,if (engine ==VCS2 && (flags &VCS2REMAP )) engine =BCS ; - eb->flags = eb_engine_map[engine]; +if ((flags &I915 ) && engine ==VCS ) { + eb->flags =0 ; + }else { + eb->flags = eb_engine_map[engine]; + } } static void
@@ -862,6 +885,23 @@ get_status_objects(struct workload *wrk)return wrk->status_object; } +static struct ctx * +__get_ctx (struct workload *wrk,struct w_step *w) +{ +return &wrk->ctx_list[w->context *2 ]; +} + +static uint32_t +get_ctxid (struct workload *wrk,struct w_step *w) +{ +struct ctx *ctx =__get_ctx (wrk, w); + +if (ctx->targets_instance && ctx->wants_balance && w->engine ==VCS ) +return wrk->ctx_list[w->context *2 +1 ].id; +else +return wrk->ctx_list[w->context *2 ].id; +} +static void alloc_step_batch (struct workload *wrk,struct w_step *w,unsigned int flags) {
@@ -914,7 +954,7 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags) w->eb.buffers_ptr =to_user_pointer (w->obj); w->eb.buffer_count = j +1 ; - w->eb.rsvd1 = wrk->ctx_list[w->context].id; + w->eb.rsvd1 =get_ctxid (wrk, w);if (flags &SWAPVCS && engine ==VCS1 ) engine =VCS2 ;
@@ -927,17 +967,29 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags)printf ("%x|" , w->obj[i].handle);printf (" %10lu flags=%llx bb=%x[%u] ctx[%u]=%u\n" , w->bb_sz, w->eb.flags, w->bb_handle, j, w->context, - wrk->ctx_list[w->context].id); +get_ctxid (wrk, w));#endif } +static void __ctx_set_prio (uint32_t ctx_id,unsigned int prio) +{ +struct drm_i915_gem_context_param param = { + .ctx_id = ctx_id, + .param =I915_CONTEXT_PARAM_PRIORITY , + .value = prio, + }; + +if (prio) +gem_context_set_param (fd, ¶m); +} +static void prepare_workload (unsigned int id,struct workload *wrk,unsigned int flags) {unsigned int ctx_vcs =0 ;int max_ctx =-1 ;struct w_step *w; -int i; +int i, j; wrk->id = id; wrk->prng =rand ();
@@ -968,44 +1020,174 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) } } +/* +* Pre-scan workload steps to allocate context list storage. +*/ for (i =0 , w = wrk->steps; i < wrk->nr_steps; i++, w++) { -if ((int )w->context > max_ctx) { -int delta = w->context +1 - wrk->nr_ctxs; +int ctx = w->context *2 +1 ;/* Odd slots are special. */ +int delta; + +if (ctx <= max_ctx) +continue ; + + delta = ctx +1 - wrk->nr_ctxs; + + wrk->nr_ctxs += delta; + wrk->ctx_list =realloc (wrk->ctx_list, + wrk->nr_ctxs *sizeof (*wrk->ctx_list)); +memset (&wrk->ctx_list[wrk->nr_ctxs - delta],0 , + delta *sizeof (*wrk->ctx_list)); + + max_ctx = ctx; + } + +/* +* Identify if contexts target specific engine instances and if they +* want to be balanced. +*/ +for (j =0 ; j < wrk->nr_ctxs; j +=2 ) { +bool targets = false; +bool balance = false; + +for (i =0 , w = wrk->steps; i < wrk->nr_steps; i++, w++) { +if (w->type !=BATCH ) +continue ; + +if (w->context != (j /2 )) +continue ; - wrk->nr_ctxs += delta; - wrk->ctx_list =realloc (wrk->ctx_list, - wrk->nr_ctxs * -sizeof (*wrk->ctx_list)); -memset (&wrk->ctx_list[wrk->nr_ctxs - delta],0 , - delta *sizeof (*wrk->ctx_list)); +if (w->engine ==VCS ) + balance = true; +else + targets = true; + } - max_ctx = w->context; +if (flags &I915 ) { + wrk->ctx_list[j].targets_instance = targets; + wrk->ctx_list[j].wants_balance = balance; } + } -if (!wrk->ctx_list[w->context].id) { -struct drm_i915_gem_context_create arg = {}; +/* +* Create and configure contexts. +*/ +for (i =0 ; i < wrk->nr_ctxs; i +=2 ) { +struct ctx *ctx = &wrk->ctx_list[i]; +uint32_t ctx_id, share_ctx =0 ; -drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &arg); -igt_assert (arg.ctx_id); +if (ctx->id) +continue ; - wrk->ctx_list[w->context].id = arg.ctx_id; +if (flags &I915 ) { +struct local_drm_i915_gem_context_create_v2 args = { }; -if (flags &GLOBAL_BALANCE ) { - wrk->ctx_list[w->context].static_vcs = context_vcs_rr; - context_vcs_rr ^=1 ; - }else { - wrk->ctx_list[w->context].static_vcs = ctx_vcs; - ctx_vcs ^=1 ; - } +/* Find existing context to share ppgtt with. */ +for (j =0 ; j < wrk->nr_ctxs; j++) { +if (!wrk->ctx_list[j].id) +continue ; -if (wrk->prio) { -struct drm_i915_gem_context_param param = { - .ctx_id = arg.ctx_id, - .param =I915_CONTEXT_PARAM_PRIORITY , - .value = wrk->prio, - }; -gem_context_set_param (fd, ¶m); + args.flags |=LOCAL_I915_GEM_CONTEXT_SHARE_GTT ; + args.share_ctx = share_ctx = + wrk->ctx_list[j].id; +break ; } + +if (!ctx->targets_instance) + args.flags |=LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE ; + +drmIoctl (fd,LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE , + &args); + + ctx_id = args.ctx_id; + }else { +struct drm_i915_gem_context_create args = {}; + +drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &args); + ctx_id = args.ctx_id; + } + +igt_assert (ctx_id); + ctx->id = ctx_id; + +if (flags &GLOBAL_BALANCE ) { + ctx->static_vcs = context_vcs_rr; + context_vcs_rr ^=1 ; + }else { + ctx->static_vcs = ctx_vcs; + ctx_vcs ^=1 ; + } + +__ctx_set_prio (ctx_id, wrk->prio); + +/* +* Do we need a separate context to satisfy this workloads which +* both want to target specific engines and be balanced by i915? +*/ +if ((flags &I915 ) && ctx->wants_balance && + ctx->targets_instance) { +struct local_drm_i915_gem_context_create_v2 args = {}; + +igt_assert (share_ctx); + + args.flags =LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE | +LOCAL_I915_GEM_CONTEXT_SHARE_GTT ; + args.share_ctx = share_ctx; + +drmIoctl (fd,LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE , + &args); + +igt_assert (args.ctx_id); + ctx_id = args.ctx_id; + wrk->ctx_list[i +1 ].id = args.ctx_id; + +__ctx_set_prio (ctx_id, wrk->prio); + } + +if (ctx->wants_balance) { +#define LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 + +struct local_i915_user_extension { +__u64 next_extension; +__u64 name; + }; + +struct local_i915_context_engines_load_balance { +struct local_i915_user_extension base; + +__u64 flags;/* all undefined flags must be zero */ +__u64 engines_mask; + +__u64 mbz[4 ];/* reserved for future use; must be zero */ + } load_balance = { + .base.name =LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE , + .engines_mask =-1 , + }; + +struct local_i915_context_param_engines { +__u64 extensions; + +struct { +__u16 class;/* see enum drm_i915_gem_engine_class */ +__u16 instance; + } engines[2 ]; + } __attribute__((packed)) set_engines = { + .extensions =to_user_pointer (&load_balance), + .engines = { + { .class =I915_ENGINE_CLASS_VIDEO , + .instance =0 }, + { .class =I915_ENGINE_CLASS_VIDEO , + .instance =1 }, + }, + }; + +struct drm_i915_gem_context_param param = { + .ctx_id = ctx_id, + .param =LOCAL_I915_CONTEXT_PARAM_ENGINES , + .size =sizeof (set_engines), + .value =to_user_pointer (&set_engines), + }; + +gem_context_set_param (fd, ¶m); } }
@@ -1380,7 +1562,7 @@ static enum intel_engine_id context_balance(const struct workload_balancer *balancer, struct workload *wrk, struct w_step *w) { - return get_vcs_engine(wrk->ctx_list[w->context].static_vcs); + return get_vcs_engine(__get_ctx(wrk, w)->static_vcs); } static unsigned int
@@ -1574,6 +1756,12 @@ static const struct workload_balancer all_balancers[] = { .get_qd = get_engine_busy, .balance = busy_avg_balance, }, + { + .id = 11, + .name = "i915", + .desc = "i915 balancing.", + .flags = I915, + }, }; static unsigned int
@@ -1952,7 +2140,8 @@ static void *run_workload(void *data) last_sync = false; wrk->nr_bb[engine]++; -if (engine ==VCS && wrk->balancer) { +if (engine ==VCS && wrk->balancer && + wrk->balancer->balance) { engine = wrk->balancer->balance (wrk->balancer, wrk, w); wrk->nr_bb[engine]++;
@@ -2379,6 +2568,12 @@ int main(int argc, char **argv)return 1 ; } +if ((flags &VCS2REMAP ) && (flags &I915 )) { +if (verbose) +fprintf (stderr,"VCS remapping not supported with i915 balancing!\n" ); +return 1 ; + } +if (!nop_calibration) {if (verbose >1 ) printf("Calibrating nop delay with %u%% tolerance...\n",
@@ -2464,11 +2659,17 @@ int main(int argc, char **argv)printf ("%u client%s.\n" , clients, clients >1 ?"s" :"" );if (flags &SWAPVCS )printf ("Swapping VCS rings between clients.\n" ); -if (flags &GLOBAL_BALANCE ) -printf ("Using %s balancer in global mode.\n" , - balancer->name); -else if (balancer) +if (flags &GLOBAL_BALANCE ) { +if (flags &I915 ) { +printf ("Ignoring global balancing with i915!\n" ); + flags &= ~GLOBAL_BALANCE ; + }else { +printf ("Using %s balancer in global mode.\n" , + balancer->name); + } + }else if (balancer) {printf ("Using %s balancer.\n" , balancer->name); + } }if (master_workload >=0 && clients ==1 )
@@ -2485,7 +2686,7 @@ int main(int argc, char **argv)if (flags &SWAPVCS && i &1 ) flags_ &= ~SWAPVCS ; -if (flags &GLOBAL_BALANCE ) { +if ((flags &GLOBAL_BALANCE ) && !(flags &I915 )) { w[i]->balancer = &global_balancer; w[i]->global_wrk = w[0 ]; w[i]->global_balancer = balancer;
scripts/media-bench.pl +6 -3
@@ -49,10 +49,11 @@ my $nop; my %opts; my @balancers = ( 'rr', 'rand', 'qd', 'qdr', 'qdavg', 'rt', 'rtr', 'rtavg', - 'context', 'busy', 'busy-avg' ); + 'context', 'busy', 'busy-avg', 'i915' ); my %bal_skip_H = ( 'rr' => 1, 'rand' => 1, 'context' => 1, , 'busy' => 1, - 'busy-avg' => 1 ); -my %bal_skip_R = ( 'context' => 1 ); + 'busy-avg' => 1, 'i915' => 1 ); +my %bal_skip_R = ( 'context' => 1, 'i915' => 1 ); +my %bal_skip_G = ( 'i915' => 1 ); my @workloads = ( 'media_load_balance_17i7.wsim',
@@ -498,6 +499,8 @@ foreach my $wrk (@saturation_workloads) { my $bid; if ($bal ne '') { + next GBAL if $G =~ '-G' and exists $bal_skip_G{$bal}; + push @xargs, "-b $bal"; push @xargs, '-R' unless exists $bal_skip_R{$bal}; push @xargs, $G if $G ne '';
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 5/17 gem_wsim: Use IGT uapi headers
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
We are moving towards bumping the uAPI headers more often instead of using too much local struct/ioctl/param definitions since the latter are more challenging for rebase and maintenance.
--- benchmarks/gem_wsim.c | 68 +++++++++++-------------------------------- 1 file changed, 17 insertions(+), 51 deletions(-)
benchmarks/gem_wsim.c +17 -51
@@ -41,7 +41,6 @@#include <limits.h> #include <pthread.h> -#include "intel_chipset.h" #include "intel_reg.h" #include "drm.h"
@@ -56,23 +55,6 @@#include "ewma.h" -#define LOCAL_I915_EXEC_FENCE_IN (1<<16) -#define LOCAL_I915_EXEC_FENCE_OUT (1<<17) - -struct local_drm_i915_gem_context_create_v2 { -/* output: id of new context*/ -__u32 ctx_id; -__u32 flags; -#define LOCAL_I915_GEM_CONTEXT_SHARE_GTT 0x1 -#define LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE 0x2 -__u32 share_ctx; -__u32 pad; -}; - -#define LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct local_drm_i915_gem_context_create_v2) - -#define LOCAL_I915_CONTEXT_PARAM_ENGINES 0x7 -enum intel_engine_id {RCS ,BCS ,
@@ -873,7 +855,7 @@ eb_update_flags(struct w_step *w, enum intel_engine_id engine,igt_assert (w->emit_fence <=0 );if (w->emit_fence) - w->eb.flags |=LOCAL_I915_EXEC_FENCE_OUT ; + w->eb.flags |=I915_EXEC_FENCE_OUT ; } static struct drm_i915_gem_exec_object2 *
@@ -1079,24 +1061,23 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)continue ;if (flags &I915 ) { -struct local_drm_i915_gem_context_create_v2 args = { }; +struct drm_i915_gem_context_create_v2 args = { };/* Find existing context to share ppgtt with. */ for (j =0 ; j < wrk->nr_ctxs; j++) {if (!wrk->ctx_list[j].id)continue ; - args.flags |=LOCAL_I915_GEM_CONTEXT_SHARE_GTT ; + args.flags |=I915_GEM_CONTEXT_SHARE_GTT ; args.share_ctx = share_ctx = wrk->ctx_list[j].id;break ; }if (!ctx->targets_instance) - args.flags |=LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE ; + args.flags |=I915_GEM_CONTEXT_SINGLE_TIMELINE ; -drmIoctl (fd,LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE , - &args); +drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &args); ctx_id = args.ctx_id; }else {
@@ -1125,16 +1106,15 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)*/ if ((flags &I915 ) && ctx->wants_balance && ctx->targets_instance) { -struct local_drm_i915_gem_context_create_v2 args = {}; +struct drm_i915_gem_context_create_v2 args = {};igt_assert (share_ctx); - args.flags =LOCAL_I915_GEM_CONTEXT_SINGLE_TIMELINE | -LOCAL_I915_GEM_CONTEXT_SHARE_GTT ; + args.flags =I915_GEM_CONTEXT_SINGLE_TIMELINE | +I915_GEM_CONTEXT_SHARE_GTT ; args.share_ctx = share_ctx; -drmIoctl (fd,LOCAL_DRM_IOCTL_I915_GEM_CONTEXT_CREATE , - &args); +drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &args);igt_assert (args.ctx_id); ctx_id = args.ctx_id;
@@ -1144,24 +1124,10 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) }if (ctx->wants_balance) { -#define LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 - -struct local_i915_user_extension { -__u64 next_extension; -__u64 name; - }; - -struct local_i915_context_engines_load_balance { -struct local_i915_user_extension base; - -__u64 flags;/* all undefined flags must be zero */ -__u64 engines_mask; - -__u64 mbz[4 ];/* reserved for future use; must be zero */ - } load_balance = { - .base.name =LOCAL_I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE , - .engines_mask =-1 , - }; +struct i915_context_engines_load_balance load_balance = + { .base.name =I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE , + .engines_mask =-1 , + };struct local_i915_context_param_engines {__u64 extensions;
@@ -1182,7 +1148,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)struct drm_i915_gem_context_param param = { .ctx_id = ctx_id, - .param =LOCAL_I915_CONTEXT_PARAM_ENGINES , + .param =I915_CONTEXT_PARAM_ENGINES , .size =sizeof (set_engines), .value =to_user_pointer (&set_engines), };
@@ -1994,16 +1960,16 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,igt_assert (tgt >=0 && tgt < w->idx);igt_assert (wrk->steps[tgt].emit_fence >0 ); - w->eb.flags |=LOCAL_I915_EXEC_FENCE_IN ; + w->eb.flags |=I915_EXEC_FENCE_IN ; w->eb.rsvd2 = wrk->steps[tgt].emit_fence; } -if (w->eb.flags &LOCAL_I915_EXEC_FENCE_OUT ) +if (w->eb.flags &I915_EXEC_FENCE_OUT )gem_execbuf_wr (fd, &w->eb);else gem_execbuf (fd, &w->eb); -if (w->eb.flags &LOCAL_I915_EXEC_FENCE_OUT ) { +if (w->eb.flags &I915_EXEC_FENCE_OUT ) { w->emit_fence = w->eb.rsvd2 >>32 ;igt_assert (w->emit_fence >0 ); }
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 6/17 gem_wsim: Fix shadowed local
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
--- benchmarks/gem_wsim.c | 1 - 1 file changed, 1 deletion(-)
benchmarks/gem_wsim.c +0 -1
@@ -1170,7 +1170,6 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)*/ for (i =0 , w = wrk->steps; i < wrk->nr_steps; i++, w++) {struct w_step *w2; -int j;if (w->type !=PREEMPTION )continue ;
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/17 gem_wsim: Factor out common error handling
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
There is a repeated pattern with error handling which can be moved to a macro to for better readability in the command parsing loop.
--- benchmarks/gem_wsim.c | 244 +++++++++++++++--------------------------- 1 file changed, 88 insertions(+), 156 deletions(-)
benchmarks/gem_wsim.c +88 -156
@@ -290,6 +290,27 @@ parse_dependencies(unsigned int nr_steps, struct w_step *w, char *_desc)return 0 ; } +static void __attribute__((format (printf,1 ,2 ))) +wsim_err (const char *fmt, ...) +{ +va_list ap; + +if (!verbose) +return ; + +va_start (ap, fmt); +vfprintf (stderr, fmt, ap); +va_end (ap); +} + +#define check_arg (cond, fmt, ...) \ +{ \ + if (cond) { \ + wsim_err(fmt, __VA_ARGS__); \ + return NULL; \ + } \ +} +static struct workload *parse_workload (struct w_arg *arg,unsigned int flags,struct workload *app_w) {
@@ -320,14 +341,9 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <=0 ) { -if (verbose) -fprintf (stderr, -"Invalid delay at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp <=0 , +"Invalid delay at step %u!\n" , + nr_steps); step.type =DELAY ; step.delay = tmp; goto add_step;
@@ -336,14 +352,9 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <=0 ) { -if (verbose) -fprintf (stderr, -"Invalid period at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp <=0 , +"Invalid period at step %u!\n" , + nr_steps); step.type =PERIOD ; step.period = tmp; goto add_step;
@@ -353,25 +364,17 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)while ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <=0 && nr ==0 ) { -if (verbose) -fprintf (stderr, -"Invalid context at step %u!\n" , - nr_steps); -return NULL ; - } - -if (nr ==0 ) { +check_arg (nr ==0 && tmp <=0 , +"Invalid context at step %u!\n" , + nr_steps); +check_arg (nr >1 , +"Invalid priority format at step %u!\n" , + nr_steps); + +if (nr ==0 ) step.context = tmp; - }else if (nr ==1 ) { +else step.priority = tmp; - }else { -if (verbose) -fprintf (stderr, -"Invalid priority format at step %u!\n" , - nr_steps); -return NULL ; - } nr++; }
@@ -382,15 +385,10 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp >=0 || - ((int )nr_steps + tmp) <0 ) { -if (verbose) -fprintf (stderr, -"Invalid sync target at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp >=0 || + ((int )nr_steps + tmp) <0 , +"Invalid sync target at step %u!\n" , + nr_steps); step.type =SYNC ; step.target = tmp; goto add_step;
@@ -399,14 +397,9 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <0 ) { -if (verbose) -fprintf (stderr, -"Invalid throttle at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp <0 , +"Invalid throttle at step %u!\n" , + nr_steps); step.type =THROTTLE ; step.throttle = tmp; goto add_step;
@@ -415,14 +408,9 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <0 ) { -if (verbose) -fprintf (stderr, -"Invalid qd throttle at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp <0 , +"Invalid qd throttle at step %u!\n" , + nr_steps); step.type =QD_THROTTLE ; step.throttle = tmp; goto add_step;
@@ -431,14 +419,9 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp >=0 ) { -if (verbose) -fprintf (stderr, -"Invalid sw fence signal at step %u!\n" , - nr_steps); -return NULL ; - } - +check_arg (tmp >=0 , +"Invalid sw fence signal at step %u!\n" , + nr_steps); step.type =SW_FENCE_SIGNAL ; step.target = tmp; goto add_step;
@@ -451,31 +434,20 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)while ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { tmp =atoi (field); -if (tmp <=0 && nr ==0 ) { -if (verbose) -fprintf (stderr, -"Invalid context at step %u!\n" , - nr_steps); -return NULL ; - }else if (tmp <0 && nr ==1 ) { -if (verbose) -fprintf (stderr, -"Invalid preemption period at step %u!\n" , - nr_steps); -return NULL ; - } - -if (nr ==0 ) { +check_arg (nr ==0 && tmp <=0 , +"Invalid context at step %u!\n" , + nr_steps); +check_arg (nr ==1 && tmp <0 , +"Invalid preemption period at step %u!\n" , + nr_steps); +check_arg (nr >1 , +"Invalid preemption format at step %u!\n" , + nr_steps); + +if (nr ==0 ) step.context = tmp; - }else if (nr ==1 ) { +else step.period = tmp; - }else { -if (verbose) -fprintf (stderr, -"Invalid preemption format at step %u!\n" , - nr_steps); -return NULL ; - } nr++; }
@@ -485,13 +457,8 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } tmp =atoi (field); -if (tmp <0 ) { -if (verbose) -fprintf (stderr, -"Invalid ctx id at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (tmp <0 ,"Invalid ctx id at step %u!\n" , + nr_steps); step.context = tmp; valid++;
@@ -512,13 +479,8 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } } -if (old_valid == valid) { -if (verbose) -fprintf (stderr, -"Invalid engine id at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (old_valid == valid, +"Invalid engine id at step %u!\n" , nr_steps); }if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) {
@@ -528,25 +490,19 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) fstart =NULL ; tmpl =strtol (field, &sep,10 ); -if (tmpl <=0 || tmpl ==LONG_MIN || tmpl ==LONG_MAX ) { -if (verbose) -fprintf (stderr, -"Invalid duration at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (tmpl <=0 || tmpl ==LONG_MIN || + tmpl ==LONG_MAX , +"Invalid duration at step %u!\n" , nr_steps); step.duration.min = tmpl;if (sep && *sep =='-' ) { tmpl =strtol (sep +1 ,NULL ,10 ); -if (tmpl <=0 || tmpl <= step.duration.min || - tmpl ==LONG_MIN || tmpl ==LONG_MAX ) { -if (verbose) -fprintf (stderr, -"Invalid duration range at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (tmpl <=0 || + tmpl <= step.duration.min || + tmpl ==LONG_MIN || + tmpl ==LONG_MAX , +"Invalid duration range at step %u!\n" , + nr_steps); step.duration.max = tmpl; }else { step.duration.max = step.duration.min;
@@ -559,13 +515,8 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) fstart =NULL ; tmp =parse_dependencies (nr_steps, &step, field); -if (tmp <0 ) { -if (verbose) -fprintf (stderr, -"Invalid dependency at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (tmp <0 , +"Invalid dependency at step %u!\n" , nr_steps); valid++; }
@@ -573,25 +524,16 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { fstart =NULL ; -if (strlen (field) !=1 || - (field[0 ] !='0' && field[0 ] !='1' )) { -if (verbose) -fprintf (stderr, -"Invalid wait boolean at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (strlen (field) !=1 || + (field[0 ] !='0' && field[0 ] !='1' ), +"Invalid wait boolean at step %u!\n" , + nr_steps); step.sync = field[0 ] -'0' ; valid++; } -if (valid !=5 ) { -if (verbose) -fprintf (stderr,"Invalid record at step %u!\n" , - nr_steps); -return NULL ; - } +check_arg (valid !=5 ,"Invalid record at step %u!\n" , nr_steps); step.type =BATCH ;
@@ -636,15 +578,10 @@ add_step:for (i =0 ; i < nr_steps; i++) {for (j =0 ; j < steps[i].fence_deps.nr; j++) { tmp = steps[i].idx + steps[i].fence_deps.list[j]; -if (tmp <0 || tmp >= i || - (steps[tmp].type !=BATCH && - steps[tmp].type !=SW_FENCE )) { -if (verbose) -fprintf (stderr, -"Invalid dependency target %u!\n" , - i); -return NULL ; - } +check_arg (tmp <0 || tmp >= i || + (steps[tmp].type !=BATCH && + steps[tmp].type !=SW_FENCE ), +"Invalid dependency target %u!\n" , i); steps[tmp].emit_fence =-1 ; } }
@@ -653,14 +590,9 @@ add_step:for (i =0 ; i < nr_steps; i++) {if (steps[i].type ==SW_FENCE_SIGNAL ) { tmp = steps[i].idx + steps[i].target; -if (tmp <0 || tmp >= i || - steps[tmp].type !=SW_FENCE ) { -if (verbose) -fprintf (stderr, -"Invalid sw fence target %u!\n" , - i); -return NULL ; - } +check_arg (tmp <0 || tmp >= i || + steps[tmp].type !=SW_FENCE , +"Invalid sw fence target %u!\n" , i); } }
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/17 gem_wsim: More wsim_err
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
A few more opportunities to compact the code by using the error logging helper.
--- benchmarks/gem_wsim.c | 54 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-)
benchmarks/gem_wsim.c +15 -39
@@ -2366,9 +2366,7 @@ int main(int argc, char **argv)switch (c) {case 'W' :if (master_workload >=0 ) { -if (verbose) -fprintf (stderr, -"Only one master workload can be given!\n" ); +wsim_err ("Only one master workload can be given!\n" );return 1 ; } master_workload = nr_w_args;
@@ -2381,9 +2379,7 @@ int main(int argc, char **argv)break ;case 'a' :if (append_workload_arg) { -if (verbose) -fprintf (stderr, -"Only one append workload can be given!\n" ); +wsim_err ("Only one append workload can be given!\n" );return 1 ; } append_workload_arg = optarg;
@@ -2444,10 +2440,8 @@ int main(int argc, char **argv) }if (!balancer) { -if (verbose) -fprintf (stderr, -"Unknown balancing mode '%s'!\n" , - optarg); +wsim_err ("Unknown balancing mode '%s'!\n" , + optarg);return 1 ; }break ;
@@ -2460,14 +2454,12 @@ int main(int argc, char **argv) }if ((flags &HEARTBEAT ) && !(flags &SEQNO )) { -if (verbose) -fprintf (stderr,"Heartbeat needs a seqno based balancer!\n" ); +wsim_err ("Heartbeat needs a seqno based balancer!\n" );return 1 ; }if ((flags &VCS2REMAP ) && (flags &I915 )) { -if (verbose) -fprintf (stderr,"VCS remapping not supported with i915 balancing!\n" ); +wsim_err ("VCS remapping not supported with i915 balancing!\n" );return 1 ; }
@@ -2484,31 +2476,24 @@ int main(int argc, char **argv) }if (!nr_w_args) { -if (verbose) -fprintf (stderr,"No workload descriptor(s)!\n" ); +wsim_err ("No workload descriptor(s)!\n" );return 1 ; }if (nr_w_args >1 && clients >1 ) { -if (verbose) -fprintf (stderr, -"Cloned clients cannot be combined with multiple workloads!\n" ); +wsim_err ("Cloned clients cannot be combined with multiple workloads!\n" );return 1 ; }if ((flags &GLOBAL_BALANCE ) && !balancer) { -if (verbose) -fprintf (stderr, -"Balancer not specified in global balancing mode!\n" ); +wsim_err ("Balancer not specified in global balancing mode!\n" );return 1 ; }if (append_workload_arg) { append_workload_arg =load_workload_descriptor (append_workload_arg);if (!append_workload_arg) { -if (verbose) -fprintf (stderr, -"Failed to load append workload descriptor!\n" ); +wsim_err ("Failed to load append workload descriptor!\n" );return 1 ; } }
@@ -2517,9 +2502,7 @@ int main(int argc, char **argv)struct w_arg arg = {NULL , append_workload_arg,0 }; app_w =parse_workload (&arg, flags,NULL );if (!app_w) { -if (verbose) -fprintf (stderr, -"Failed to parse append workload!\n" ); +wsim_err ("Failed to parse append workload!\n" );return 1 ; } }
@@ -2531,18 +2514,13 @@ int main(int argc, char **argv) w_args[i].desc =load_workload_descriptor (w_args[i].filename);if (!w_args[i].desc) { -if (verbose) -fprintf (stderr, -"Failed to load workload descriptor %u!\n" , - i); +wsim_err ("Failed to load workload descriptor %u!\n" , i);return 1 ; } wrk[i] =parse_workload (&w_args[i], flags, app_w);if (!wrk[i]) { -if (verbose) -fprintf (stderr, -"Failed to parse workload %u!\n" , i); +wsim_err ("Failed to parse workload %u!\n" , i);return 1 ; } }
@@ -2602,10 +2580,8 @@ int main(int argc, char **argv)if (balancer && balancer->init) {int ret = balancer->init (balancer, w[i]);if (ret) { -if (verbose) -fprintf (stderr, -"Failed to initialize balancing! (%u=%d)\n" , - i, ret); +wsim_err ("Failed to initialize balancing! (%u=%d)\n" , + i, ret);return 1 ; } }
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 9/17 gem_wsim: Submit fence support
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Add support for submit fences in a way similar to how normal input fences are handled. Eg:
1.RCS.500-1000.0.0
1.VCS1.3000.s-1.0
1.VCS2.3000.s-2.0
Submit fences are signalled when the originating request enters the submission backend.
--- benchmarks/gem_wsim.c | 20 ++++++++++++++++---- benchmarks/wsim/README | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-)
benchmarks/gem_wsim.c +16 -4
@@ -86,6 +86,7 @@ enum w_typestruct deps {int nr; +bool submit_fence;int *list; };
@@ -254,17 +255,23 @@ parse_dependencies(unsigned int nr_steps, struct w_step *w, char *_desc) w->data_deps.list == w->fence_deps.list);while ((token =strtok_r (tstart,"/" , &tctx)) !=NULL ) { +bool submit_fence = false;char *str = token;struct deps *deps;int dep; tstart =NULL ; -if (strlen (token) >1 && token[0 ] =='f' ) { +if (str[0 ] =='-' || (str[0 ] >='0' && str[0 ] <='9' )) { + deps = &w->data_deps; + }else { +if (str[0 ] =='s' ) + submit_fence = true; +else if (str[0 ] !='f' ) +return -1 ; + deps = &w->fence_deps; str++; - }else { - deps = &w->data_deps; } dep =atoi (str);
@@ -282,6 +289,7 @@ parse_dependencies(unsigned int nr_steps, struct w_step *w, char *_desc) sizeof(*deps->list) * deps->nr);igt_assert (deps->list); deps->list[deps->nr -1 ] = dep; + deps->submit_fence = submit_fence; } }
@@ -1891,7 +1899,11 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,igt_assert (tgt >=0 && tgt < w->idx);igt_assert (wrk->steps[tgt].emit_fence >0 ); - w->eb.flags |=I915_EXEC_FENCE_IN ; +if (w->fence_deps.submit_fence) + w->eb.flags |=I915_EXEC_FENCE_SUBMIT ; +else + w->eb.flags |=I915_EXEC_FENCE_IN ; + w->eb.rsvd2 = wrk->steps[tgt].emit_fence; }
benchmarks/wsim/README +17 -0
@@ -114,6 +114,23 @@ runnable. When the second RCS batch completes the standalone fence is signaled which allows the two VCS batches to be executed. Finally we wait until the both VCS batches have completed before starting the (optional) next iteration. +Submit fences +------------- + +Submit fences are a type of input fence which are signalled when the originating +batch buffer is submitted to the GPU. (In contrary to normal sync fences, which +are signalled when completed.) + +Submit fences have the identical syntax as the sync fences with the lower-case +'s' being used to select them. Eg: + + 1.RCS.500-1000.0.0 + 1.VCS1.3000.s-1.0 + 1.VCS2.3000.s-2.0 + +Here VCS1 and VCS2 batches will only be submitted for executing once the RCS +batch enters the GPU. + Context priority ----------------
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 10/17 gem_wsim: Extract str to engine lookup
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
--- benchmarks/gem_wsim.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
benchmarks/gem_wsim.c +21 -13
@@ -319,6 +319,18 @@ wsim_err(const char *fmt, ...) } \ } +static int str_to_engine (const char *str) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (ring_str_map); i++) { +if (!strcasecmp (str, ring_str_map[i])) +return i; + } + +return -1 ; +} +static struct workload *parse_workload (struct w_arg *arg,unsigned int flags,struct workload *app_w) {
@@ -473,22 +485,18 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) }if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { -unsigned int old_valid = valid; - fstart =NULL ; -for (i =0 ; i <ARRAY_SIZE (ring_str_map); i++) { -if (!strcasecmp (field, ring_str_map[i])) { - step.engine = i; -if (step.engine ==BCS ) - bcs_used = true; - valid++; -break ; - } - } - -check_arg (old_valid == valid, + i =str_to_engine (field); +check_arg (i <0 ,"Invalid engine id at step %u!\n" , nr_steps); +if (i >=0 ) + valid++; + + step.engine = i; + +if (step.engine ==BCS ) + bcs_used = true; }if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) {
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/17 gem_wsim: Engine map support
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Support new i915 uAPI for configuring contexts with engine maps.
Please refer to the README file for more detailed explanation.
--- benchmarks/gem_wsim.c | 212 ++++++++++++++++++++++++++++++++++------- benchmarks/wsim/README | 17 +++- 2 files changed, 192 insertions(+), 37 deletions(-)
benchmarks/gem_wsim.c +176 -36
@@ -56,6 +56,7 @@#include "ewma.h" enum intel_engine_id { +DEFAULT ,RCS ,BCS ,VCS ,
@@ -80,7 +81,8 @@ enum w_typeSW_FENCE ,SW_FENCE_SIGNAL ,CTX_PRIORITY , - PREEMPTION +PREEMPTION , + ENGINE_MAP };struct deps
@@ -114,6 +116,10 @@ struct w_stepint throttle;int fence_signal;int priority; +struct { +unsigned int engine_map_count; +enum intel_engine_id *engine_map; + }; };/* Implementation details */
@@ -143,6 +149,8 @@ DECLARE_EWMA(uint64_t, rt, 4, 2)struct ctx {uint32_t id;int priority; +unsigned int engine_map_count; +enum intel_engine_id *engine_map;bool targets_instance;bool wants_balance;unsigned int static_vcs;
@@ -201,10 +209,10 @@ struct workloadint fd;bool first;unsigned int num_engines; -unsigned int engine_map[5 ]; +unsigned int engine_map[NUM_ENGINES ];uint64_t t_prev; -uint64_t prev[5 ]; -double busy[5 ]; +uint64_t prev[NUM_ENGINES ]; +double busy[NUM_ENGINES ]; } busy_balancer; };
@@ -235,6 +243,7 @@ static int fd;#define REG (x) (volatile uint32_t *)((volatile char *)igt_global_mmio + x)static const char *ring_str_map[NUM_ENGINES ] = { + [DEFAULT ] ="DEFAULT" , [RCS ] ="RCS" , [BCS ] ="BCS" , [VCS ] ="VCS" ,
@@ -331,6 +340,37 @@ static int str_to_engine(const char *str)return -1 ; } +static int parse_engine_map (struct w_step *step,const char *_str) +{ +char *token, *tctx =NULL , *tstart = (char *)_str; + +while ((token =strtok_r (tstart,"|" , &tctx))) { +enum intel_engine_id engine; + + tstart =NULL ; + +if (!strcmp (token,"DEFAULT" )) +return -1 ; +else if (!strcmp (token,"VCS" )) +return -1 ; + + engine =str_to_engine (token); +if ((int )engine <0 ) +return -1 ; + +if (engine !=VCS1 && engine !=VCS2 ) +return -1 ;/* TODO */ + + step->engine_map_count++; + step->engine_map =realloc (step->engine_map, + step->engine_map_count * +sizeof (step->engine_map[0 ])); + step->engine_map[step->engine_map_count -1 ] = engine; + } + +return 0 ; +} +static struct workload *parse_workload (struct w_arg *arg,unsigned int flags,struct workload *app_w) {
@@ -449,6 +489,33 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) }else if (!strcmp (field,"f" )) { step.type =SW_FENCE ; goto add_step; + }else if (!strcmp (field,"M" )) { +unsigned int nr =0 ; +while ((field =strtok_r (fstart,"." , &fctx)) != +NULL ) { + tmp =atoi (field); +check_arg (nr ==0 && tmp <=0 , +"Invalid context at step %u!\n" , + nr_steps); +check_arg (nr >1 , +"Invalid engine map format at step %u!\n" , + nr_steps); + +if (nr ==0 ) { + step.context = tmp; + }else { + tmp =parse_engine_map (&step, + field); +check_arg (tmp <0 , +"Invalid engine map list at step %u!\n" , + nr_steps); + } + + nr++; + } + + step.type =ENGINE_MAP ; + goto add_step; }else if (!strcmp (field,"X" )) {unsigned int nr =0 ; while ((field = strtok_r(fstart, ".", &fctx)) !=
@@ -490,9 +557,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) i =str_to_engine (field);check_arg (i <0 ,"Invalid engine id at step %u!\n" , nr_steps); -if (i >=0 ) - valid++; - + valid++; step.engine = i;if (step.engine ==BCS )
@@ -769,6 +834,7 @@ terminate_bb(struct w_step *w, unsigned int flags) }static const unsigned int eb_engine_map[NUM_ENGINES ] = { + [DEFAULT ] =I915_EXEC_DEFAULT , [RCS ] =I915_EXEC_RENDER , [BCS ] =I915_EXEC_BLT , [VCS ] =I915_EXEC_BSD ,
@@ -785,18 +851,42 @@ eb_set_engine(struct drm_i915_gem_execbuffer2 *eb,if (engine ==VCS2 && (flags &VCS2REMAP )) engine =BCS ; -if ((flags &I915 ) && engine ==VCS ) { +if ((flags &I915 ) && engine ==VCS ) eb->flags =0 ; - }else { +else eb->flags = eb_engine_map[engine]; +} + +static unsigned int +find_engine_in_map (struct ctx *ctx,enum intel_engine_id engine) +{ +unsigned int i; + +for (i =0 ; i < ctx->engine_map_count; i++) { +if (ctx->engine_map[i] == engine) +return i +1 ; } + +igt_assert (0 ); +return 0 ; +} + +static struct ctx * +__get_ctx (struct workload *wrk,struct w_step *w) +{ +return &wrk->ctx_list[w->context *2 ]; }static void -eb_update_flags (struct w_step *w,enum intel_engine_id engine, -unsigned int flags) +eb_update_flags (struct workload *wrk,struct w_step *w, +enum intel_engine_id engine,unsigned int flags) { -eb_set_engine (&w->eb, engine, flags); +struct ctx *ctx =__get_ctx (wrk, w); + +if (ctx->engine_map) + w->eb.flags =find_engine_in_map (ctx, engine); +else +eb_set_engine (&w->eb, engine, flags); w->eb.flags |=I915_EXEC_HANDLE_LUT ; w->eb.flags |=I915_EXEC_NO_RELOC ;
@@ -815,12 +905,6 @@ get_status_objects(struct workload *wrk)return wrk->status_object; } -static struct ctx * -__get_ctx (struct workload *wrk,struct w_step *w) -{ -return &wrk->ctx_list[w->context *2 ]; -} -static uint32_t get_ctxid (struct workload *wrk,struct w_step *w) {
@@ -890,7 +974,7 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags) engine =VCS2 ; else if (flags & SWAPVCS && engine == VCS2) engine =VCS1 ; -eb_update_flags (w, engine, flags); +eb_update_flags (wrk, w, engine, flags);#ifdef DEBUG printf ("%u: %u:|" , w->idx, w->eb.buffer_count);for (i =0 ; i <= j; i++)
@@ -913,7 +997,7 @@ static void __ctx_set_prio(uint32_t ctx_id, unsigned int prio)gem_context_set_param (fd, ¶m); } -static void +static int prepare_workload (unsigned int id,struct workload *wrk,unsigned int flags) {unsigned int ctx_vcs =0 ;
@@ -974,30 +1058,53 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)/* * Identify if contexts target specific engine instances and if they * want to be balanced. +* +* Transfer over engine map configuration from the workload step. */ for (j =0 ; j < wrk->nr_ctxs; j +=2 ) {bool targets = false;bool balance = false;for (i =0 , w = wrk->steps; i < wrk->nr_steps; i++, w++) { -if (w->type !=BATCH ) -continue ; -if (w->context != (j /2 ))continue ; -if (w->engine ==VCS ) - balance = true; -else - targets = true; +if (w->type ==BATCH ) { +if (w->engine ==VCS ) + balance = true; +else + targets = true; + }else if (w->type ==ENGINE_MAP ) { + wrk->ctx_list[j].engine_map = w->engine_map; + wrk->ctx_list[j].engine_map_count = + w->engine_map_count; + } } -if (flags &I915 ) { - wrk->ctx_list[j].targets_instance = targets; + wrk->ctx_list[j].targets_instance = targets; +if (flags &I915 ) wrk->ctx_list[j].wants_balance = balance; + } + +/* +* Ensure VCS is not allowed with engine map contexts. +*/ +for (j =0 ; j < wrk->nr_ctxs; j +=2 ) { +for (i =0 , w = wrk->steps; i < wrk->nr_steps; i++, w++) { +if (w->context != (j /2 )) +continue ; + +if (w->type !=BATCH ) +continue ; + +if (wrk->ctx_list[j].engine_map && w->engine ==VCS ) { +wsim_err ("Batches targetting engine maps must use explicit engines!\n" ); +return -1 ; + } } } +/* * Create and configure contexts. */
@@ -1008,7 +1115,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)if (ctx->id)continue ; -if (flags &I915 ) { +if ((flags &I915 ) || ctx->engine_map) {struct drm_i915_gem_context_create_v2 args = { };/* Find existing context to share ppgtt with. */
@@ -1022,7 +1129,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)break ; } -if (!ctx->targets_instance) +if ((!ctx->engine_map && !ctx->targets_instance)) args.flags |=I915_GEM_CONTEXT_SINGLE_TIMELINE ;drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &args);
@@ -1053,7 +1160,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)* both want to target specific engines and be balanced by i915? */ if ((flags &I915 ) && ctx->wants_balance && - ctx->targets_instance) { + ctx->targets_instance && !ctx->engine_map) {struct drm_i915_gem_context_create_v2 args = {};igt_assert (share_ctx);
@@ -1071,7 +1178,33 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)__ctx_set_prio (ctx_id, wrk->prio); } -if (ctx->wants_balance) { +if (ctx->engine_map) { +struct local_i915_context_param_engines { +__u64 extensions; + +struct { +__u16 class;/* see enum drm_i915_gem_engine_class */ +__u16 instance; + } engines[ctx->engine_map_count]; + } __attribute__((packed)) set_engines; +struct drm_i915_gem_context_param param = { + .ctx_id = ctx_id, + .param =I915_CONTEXT_PARAM_ENGINES , + .size =sizeof (set_engines), + .value =to_user_pointer (&set_engines), + }; + + set_engines.extensions =0 ; + +for (j =0 ; j < ctx->engine_map_count; j++) { + set_engines.engines[j].class = +I915_ENGINE_CLASS_VIDEO ;/* FIXME */ + set_engines.engines[j].instance = + ctx->engine_map[j] -VCS1 ;/* FIXME */ + } + +gem_context_set_param (fd, ¶m); + }else if (ctx->wants_balance) {struct i915_context_engines_load_balance load_balance = { .base.name =I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE , .engines_mask =-1 ,
@@ -1151,6 +1284,8 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)alloc_step_batch (wrk, w, _flags); } + +return 0 ; }static double elapsed (const struct timespec *start,const struct timespec *end)
@@ -1888,7 +2023,7 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,uint32_t seqno =new_seqno (wrk, engine);unsigned int i; -eb_update_flags (w, engine, flags); +eb_update_flags (wrk, w, engine, flags);if (flags &SEQNO )update_bb_seqno (w, engine, seqno);
@@ -2037,7 +2172,8 @@ static void *run_workload(void *data) w->priority; }continue ; - }else if (w->type ==PREEMPTION ) { + }else if (w->type ==PREEMPTION || + w->type ==ENGINE_MAP ) {continue ; }
@@ -2595,7 +2731,11 @@ int main(int argc, char **argv) w[i]->print_stats = verbose >1 || (verbose >0 && master_workload == i); -prepare_workload (i, w[i], flags_); +if (prepare_workload (i, w[i], flags_)) { +wsim_err ("Failed to prepare workload %u!\n" , i); +return 1 ; + } +if (balancer && balancer->init) {int ret = balancer->init (balancer, w[i]);
benchmarks/wsim/README +16 -1
@@ -3,6 +3,7 @@ Workload descriptor format ctx.engine.duration_us.dependency.wait,... <uint>.<str>.<uint>[-<uint>].<int <= 0>[/<int <= 0>][...].<0|1>,... +M.<uint>.<str>[|<str>]... P|X.<uint>.<int> d|p|s|t|q|a.<int>,... f
@@ -23,10 +24,11 @@ Additional workload steps are also supported: 'q' - Throttle to n max queue depth. 'f' - Create a sync fence. 'a' - Advance the previously created sync fence. + 'M' - Set up engine map. 'P' - Context priority. 'X' - Context preemption control. -Engine ids: RCS, BCS, VCS, VCS1, VCS2, VECS +Engine ids: DEFAULT, RCS, BCS, VCS, VCS1, VCS2, VECS Example (leading spaces must not be present in the actual file): ----------------------------------------------------------------
@@ -161,3 +163,16 @@ The same context is then marked to have batches which can be preempted every Same as with context priority, context preemption commands are valid until optionally overriden by another preemption control change on the same context. + +Engine maps +----------- + +Engine maps are a per context feature which changes the way engine selection is +done in the driver. + +Example: + + 1.M.VCS1|VCS2 + +This sets up context 1 with an engine map containing VCS1 and VCS2 engine. +Submission to this context can now only reference these two engines.
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 12/17 gem_wsim: Save some lines by changing to implicit NULL checking
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
We can improve the parsing loop readability a bit more by avoiding some line breaks caused by explicit NULL checks.
--- benchmarks/gem_wsim.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
benchmarks/gem_wsim.c +15 -24
@@ -386,7 +386,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w)igt_assert (desc); -while ((_token =strtok_r (tstart,"," , &tctx)) !=NULL ) { +while ((_token =strtok_r (tstart,"," , &tctx))) { tstart =NULL ; token =strdup (_token);igt_assert (token);
@@ -394,12 +394,11 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid =0 ;memset (&step,0 ,sizeof (step)); -if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { fstart =NULL ;if (!strcmp (field,"d" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp <= 0, "Invalid delay at step %u!\n",
@@ -409,8 +408,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } }else if (!strcmp (field,"p" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp <= 0, "Invalid period at step %u!\n",
@@ -421,8 +419,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } }else if (!strcmp (field,"P" )) {unsigned int nr =0 ; -while ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +while ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n",
@@ -442,8 +439,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type =CTX_PRIORITY ; goto add_step; }else if (!strcmp (field,"s" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp >= 0 || ((int)nr_steps + tmp) < 0,
@@ -454,8 +450,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } }else if (!strcmp (field,"t" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp < 0, "Invalid throttle at step %u!\n",
@@ -465,8 +460,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } }else if (!strcmp (field,"q" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp < 0, "Invalid qd throttle at step %u!\n",
@@ -476,8 +470,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; } }else if (!strcmp (field,"a" )) { -if ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(tmp >= 0, "Invalid sw fence signal at step %u!\n",
@@ -491,8 +484,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; }else if (!strcmp (field,"M" )) {unsigned int nr =0 ; -while ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +while ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n",
@@ -518,8 +510,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) goto add_step; }else if (!strcmp (field,"X" )) {unsigned int nr =0 ; -while ((field =strtok_r (fstart,"." , &fctx)) != -NULL ) { +while ((field =strtok_r (fstart,"." , &fctx))) { tmp =atoi (field); check_arg(nr == 0 && tmp <= 0, "Invalid context at step %u!\n",
@@ -551,7 +542,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } -if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { fstart =NULL ; i =str_to_engine (field);
@@ -564,7 +555,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) bcs_used = true; } -if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) {char *sep =NULL ;long int tmpl;
@@ -592,7 +583,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } -if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { fstart =NULL ; tmp =parse_dependencies (nr_steps, &step, field);
@@ -602,7 +593,7 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) valid++; } -if ((field =strtok_r (fstart,"." , &fctx)) !=NULL ) { +if ((field =strtok_r (fstart,"." , &fctx))) { fstart =NULL ; check_arg(strlen(field) != 1 ||
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/17 gem_wsim: Compact int command parsing with a macro
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Parsing an integer workload descriptor field is a common pattern which we can extract to a helper macro and by doing so further improve the readability of the main parsing loop.
--- benchmarks/gem_wsim.c | 80 ++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 55 deletions(-)
benchmarks/gem_wsim.c +25 -55
@@ -371,6 +371,15 @@ static int parse_engine_map(struct w_step *step, const char *_str)return 0 ; } +#define int_field (_STEP_, _FIELD_, _COND_, _ERR_) \ + if ((field = strtok_r(fstart, ".", &fctx))) { \ + tmp = atoi(field); \ + check_arg(_COND_, _ERR_, nr_steps); \ + step.type = _STEP_; \ + step._FIELD_ = tmp; \ + goto add_step; \ + } \ +static struct workload *parse_workload (struct w_arg *arg,unsigned int flags,struct workload *app_w) {
@@ -398,25 +407,11 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) fstart =NULL ;if (!strcmp (field,"d" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp <=0 , -"Invalid delay at step %u!\n" , - nr_steps); - step.type =DELAY ; - step.delay = tmp; - goto add_step; - } +int_field (DELAY , delay, tmp <=0 , +"Invalid delay at step %u!\n" ); }else if (!strcmp (field,"p" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp <=0 , -"Invalid period at step %u!\n" , - nr_steps); - step.type =PERIOD ; - step.period = tmp; - goto add_step; - } +int_field (PERIOD , period, tmp <=0 , +"Invalid period at step %u!\n" ); }else if (!strcmp (field,"P" )) {unsigned int nr =0 ;while ((field =strtok_r (fstart,"." , &fctx))) {
@@ -439,46 +434,21 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type =CTX_PRIORITY ; goto add_step; }else if (!strcmp (field,"s" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp >=0 || - ((int )nr_steps + tmp) <0 , -"Invalid sync target at step %u!\n" , - nr_steps); - step.type =SYNC ; - step.target = tmp; - goto add_step; - } +int_field (SYNC , target, + tmp >=0 || ((int )nr_steps + tmp) <0 , +"Invalid sync target at step %u!\n" ); }else if (!strcmp (field,"t" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp <0 , -"Invalid throttle at step %u!\n" , - nr_steps); - step.type =THROTTLE ; - step.throttle = tmp; - goto add_step; - } +int_field (THROTTLE , throttle, + tmp <0 , +"Invalid throttle at step %u!\n" ); }else if (!strcmp (field,"q" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp <0 , -"Invalid qd throttle at step %u!\n" , - nr_steps); - step.type =QD_THROTTLE ; - step.throttle = tmp; - goto add_step; - } +int_field (QD_THROTTLE , throttle, + tmp <0 , +"Invalid qd throttle at step %u!\n" ); }else if (!strcmp (field,"a" )) { -if ((field =strtok_r (fstart,"." , &fctx))) { - tmp =atoi (field); -check_arg (tmp >=0 , -"Invalid sw fence signal at step %u!\n" , - nr_steps); - step.type =SW_FENCE_SIGNAL ; - step.target = tmp; - goto add_step; - } +int_field (SW_FENCE_SIGNAL , target, + tmp >=0 , +"Invalid sw fence signal at step %u!\n" ); }else if (!strcmp (field,"f" )) { step.type =SW_FENCE ; goto add_step;
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/17 gem_wsim: Engine map load balance command
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
A new workload command for enabling a load balanced context map (aka Virtual Engine). Example usage:
1.B
This turns on load balancing for context one, assuming it has already been configured with an engine map. Only DEFAULT engine specifier can be used with load balanced engine maps.
--- benchmarks/gem_wsim.c | 62 +++++++++++++++++++++++++++++++++++++----- benchmarks/wsim/README | 18 ++++++++++++ 2 files changed, 73 insertions(+), 7 deletions(-)
benchmarks/gem_wsim.c +55 -7
@@ -82,7 +82,8 @@ enum w_typeSW_FENCE_SIGNAL ,CTX_PRIORITY ,PREEMPTION , - ENGINE_MAP +ENGINE_MAP , + LOAD_BALANCE, };struct deps
@@ -120,6 +121,7 @@ struct w_stepunsigned int engine_map_count;enum intel_engine_id *engine_map; }; +bool load_balance; };/* Implementation details */
@@ -502,6 +504,25 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type =PREEMPTION ; goto add_step; + }else if (!strcmp (field,"B" )) { +unsigned int nr =0 ; +while ((field =strtok_r (fstart,"." , &fctx))) { + tmp =atoi (field); +check_arg (nr ==0 && tmp <=0 , +"Invalid context at step %u!\n" , + nr_steps); +check_arg (nr >0 , +"Invalid load balance format at step %u!\n" , + nr_steps); + + step.context = tmp; + step.load_balance = true; + + nr++; + } + + step.type =LOAD_BALANCE ; + goto add_step; } tmp =atoi (field);
@@ -828,7 +849,7 @@ find_engine_in_map(struct ctx *ctx, enum intel_engine_id engine)return i +1 ; } -igt_assert (0 ); +igt_assert (ctx->wants_balance);return 0 ; }
@@ -1039,12 +1060,19 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) wrk->ctx_list[j].engine_map = w->engine_map; wrk->ctx_list[j].engine_map_count = w->engine_map_count; + }else if (w->type ==LOAD_BALANCE ) { +if (!wrk->ctx_list[j].engine_map) { +wsim_err ("Load balancing needs an engine map!\n" ); +return 1 ; + } + wrk->ctx_list[j].wants_balance = + w->load_balance; } } wrk->ctx_list[j].targets_instance = targets;if (flags &I915 ) - wrk->ctx_list[j].wants_balance = balance; + wrk->ctx_list[j].wants_balance |= balance; }/*
@@ -1058,10 +1086,19 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)if (w->type !=BATCH )continue ; -if (wrk->ctx_list[j].engine_map && w->engine ==VCS ) { +if (wrk->ctx_list[j].engine_map && + !wrk->ctx_list[j].wants_balance && + (w->engine ==VCS || w->engine ==DEFAULT )) {wsim_err ("Batches targetting engine maps must use explicit engines!\n" );return -1 ; } + +if (wrk->ctx_list[j].engine_map && + wrk->ctx_list[j].wants_balance && + w->engine !=DEFAULT ) { +wsim_err ("Batches targetting load balanced maps must not use explicit engines!\n" ); +return -1 ; + } } }
@@ -1090,7 +1127,8 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)break ; } -if ((!ctx->engine_map && !ctx->targets_instance)) +if ((!ctx->engine_map && !ctx->targets_instance) || + (ctx->engine_map && ctx->wants_balance)) args.flags |=I915_GEM_CONTEXT_SINGLE_TIMELINE ;drmIoctl (fd,DRM_IOCTL_I915_GEM_CONTEXT_CREATE , &args);
@@ -1154,8 +1192,17 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) .size = sizeof(set_engines), .value = to_user_pointer(&set_engines), }; +struct i915_context_engines_load_balance load_balance = + { .base.name =I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE , + .engines_mask =-1 , + }; - set_engines.extensions =0 ; +if (ctx->wants_balance) { + set_engines.extensions = +to_user_pointer (&load_balance); + }else { + set_engines.extensions =0 ; + }for (j =0 ; j < ctx->engine_map_count; j++) { set_engines.engines[j].class =
@@ -2134,7 +2181,8 @@ static void *run_workload(void *data) }continue ; }else if (w->type ==PREEMPTION || - w->type ==ENGINE_MAP ) { + w->type ==ENGINE_MAP || + w->type ==LOAD_BALANCE ) {continue ; }
benchmarks/wsim/README +18 -0
@@ -3,6 +3,7 @@ Workload descriptor format ctx.engine.duration_us.dependency.wait,... <uint>.<str>.<uint>[-<uint>].<int <= 0>[/<int <= 0>][...].<0|1>,... +B.<uint> M.<uint>.<str>[|<str>]... P|X.<uint>.<int> d|p|s|t|q|a.<int>,...
@@ -24,6 +25,7 @@ Additional workload steps are also supported: 'q' - Throttle to n max queue depth. 'f' - Create a sync fence. 'a' - Advance the previously created sync fence. + 'B' - Turn on context load balancing. 'M' - Set up engine map. 'P' - Context priority. 'X' - Context preemption control.
@@ -176,3 +178,19 @@ Example: This sets up context 1 with an engine map containing VCS1 and VCS2 engine. Submission to this context can now only reference these two engines. + +Context load balancing +---------------------- + +Context load balancing (aka Virtual Engine) is an i915 feature where the driver +will pick the best engine (most idle) to submit to given previously configured +engine map. + +Example: + + 1.B + +This enables load balancing for context number one. + +Submissions to load balanced contexts are only allowed to use the DEFAULT engine +specifier.
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 15/17 gem_wsim: Engine bond command
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Engine bonds are an i915 uAPI applicable to load balanced contexts with engine map. They allow expression rules of engine selection between two contexts when submissions are also tied with submit fences.
Please refer to the README for a more detailed description.
--- benchmarks/gem_wsim.c | 100 ++++++++++++++++++++++++++++++++++++++--- benchmarks/wsim/README | 50 +++++++++++++++++++++ 2 files changed, 143 insertions(+), 7 deletions(-)
benchmarks/gem_wsim.c +93 -7
@@ -84,6 +84,7 @@ enum w_typePREEMPTION ,ENGINE_MAP ,LOAD_BALANCE , + BOND, };struct deps
@@ -99,6 +100,11 @@ struct w_arg {int prio; }; +struct bond { +uint64_t mask; +enum intel_engine_id master; +}; +struct w_step {/* Workload step metadata */
@@ -122,6 +128,10 @@ struct w_stepenum intel_engine_id *engine_map; };bool load_balance; +struct { +uint64_t bond_mask; +enum intel_engine_id bond_master; + }; };/* Implementation details */
@@ -153,6 +163,8 @@ struct ctx {int priority;unsigned int engine_map_count;enum intel_engine_id *engine_map; +unsigned int bond_count; +struct bond *bonds;bool targets_instance;bool wants_balance;unsigned int static_vcs;
@@ -523,6 +535,40 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type =LOAD_BALANCE ; goto add_step; + }else if (!strcmp (field,"b" )) { +unsigned int nr =0 ; +while ((field =strtok_r (fstart,"." , &fctx))) { + tmp =atoi (field); +check_arg (nr ==0 && tmp <=0 , +"Invalid context at step %u!\n" , + nr_steps); +check_arg (nr ==1 && + (tmp <-1 || tmp ==0 ), +"Invalid siblings mask at step %u!\n" , + nr_steps); +check_arg (nr >2 , +"Invalid bond format at step %u!\n" , + nr_steps); + +if (nr ==0 ) { + step.context = tmp; + }else if (nr ==1 ) { + step.bond_mask = tmp; + }else if (nr ==2 ) { + tmp =str_to_engine (field); +check_arg (tmp <=0 || + tmp ==VCS || + tmp ==DEFAULT , +"Invalid master engine at step %u!\n" , + nr_steps); + step.bond_master = tmp; + } + + nr++; + } + + step.type =BOND ; + goto add_step; } tmp =atoi (field);
@@ -1044,6 +1090,8 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)* Transfer over engine map configuration from the workload step. */ for (j =0 ; j < wrk->nr_ctxs; j +=2 ) { +struct ctx *ctx = &wrk->ctx_list[j]; +bool targets = false;bool balance = false;
@@ -1057,16 +1105,28 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags)else targets = true; }else if (w->type ==ENGINE_MAP ) { - wrk->ctx_list[j].engine_map = w->engine_map; - wrk->ctx_list[j].engine_map_count = - w->engine_map_count; + ctx->engine_map = w->engine_map; + ctx->engine_map_count = w->engine_map_count; }else if (w->type ==LOAD_BALANCE ) { -if (!wrk->ctx_list[j].engine_map) { +if (!ctx->engine_map) {wsim_err ("Load balancing needs an engine map!\n" );return 1 ; } - wrk->ctx_list[j].wants_balance = - w->load_balance; + ctx->wants_balance = w->load_balance; + }else if (w->type ==BOND ) { +if (!ctx->wants_balance) { +wsim_err ("Engine bonds need load balancing engine map!\n" ); +return 1 ; + } + ctx->bond_count++; + ctx->bonds =realloc (ctx->bonds, + ctx->bond_count * +sizeof (struct bond )); +igt_assert (ctx->bonds); + ctx->bonds[ctx->bond_count -1 ].mask = + w->bond_mask; + ctx->bonds[ctx->bond_count -1 ].master = + w->bond_master; } }
@@ -1196,6 +1256,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) { .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE, .engines_mask = -1, }; +struct i915_context_engines_bond *bonds =NULL ;if (ctx->wants_balance) { set_engines.extensions =
@@ -1211,7 +1272,31 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) ctx->engine_map[j] -VCS1 ;/* FIXME */ } +if (ctx->bond_count) { + bonds =calloc (ctx->bond_count,sizeof (*bonds)); + load_balance.base.next_extension = +to_user_pointer (&bonds[0 ]); + } + +for (j =0 ; j < ctx->bond_count; j++) { +struct i915_context_engines_bond *bond = + &bonds[j]; + +if (j < (ctx->bond_count -1 )) + bond->base.next_extension = +to_user_pointer (bond +1 ); + + bond->base.name =I915_CONTEXT_ENGINES_EXT_BOND ; + bond->master_class =I915_ENGINE_CLASS_VIDEO ; + bond->master_instance = + ctx->bonds[j].master -VCS1 ; + bond->sibling_mask = ctx->bonds[j].mask; + } +gem_context_set_param (fd, ¶m); + +if (bonds) +free (bonds); }else if (ctx->wants_balance) {struct i915_context_engines_load_balance load_balance = { .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE,
@@ -2182,7 +2267,8 @@ static void *run_workload(void *data)continue ; }else if (w->type ==PREEMPTION || w->type ==ENGINE_MAP || - w->type ==LOAD_BALANCE ) { + w->type ==LOAD_BALANCE || + w->type ==BOND ) {continue ; }
benchmarks/wsim/README +50 -0
65 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [igt-dev] [PATCH i-g-t 15/17] gem_wsim: Engine bond command
Quoting Tvrtko Ursulin (2018-10-18 16:28:13)
Quoted 27 lines
benchmarks/gem_wsim.c +16
-0@@ -1196,6 +1256,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) { .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE, .engines_mask = -1, }; +struct i915_context_engines_bond *bonds =NULL ;if (ctx->wants_balance) { set_engines.extensions =@@ -1211,7 +1272,31 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) ctx->engine_map[j] -VCS1 ;/* FIXME */ } +if (ctx->bond_count) { + bonds =calloc (ctx->bond_count,sizeof (*bonds)); + load_balance.base.next_extension = +to_user_pointer (&bonds[0 ]); + } + +for (j =0 ; j < ctx->bond_count; j++) { +struct i915_context_engines_bond *bond = + &bonds[j]; + +if (j < (ctx->bond_count -1 )) + bond->base.next_extension = +to_user_pointer (bond +1 ); + + bond->base.name =I915_CONTEXT_ENGINES_EXT_BOND ;
benchmarks/gem_wsim.c prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) · line 1299
Quoted 10 lines
benchmarks/gem_wsim.c +9
-0+ bond->master_class =I915_ENGINE_CLASS_VIDEO ; + bond->master_instance = + ctx->bonds[j].master -VCS1 ; + bond->sibling_mask = ctx->bonds[j].mask; + } +gem_context_set_param (fd, ¶m); + +if (bonds) +free (bonds);
free(NULL) is legal, so just free(bonds) here.
Looking at how you have constructed the map for the extension, I'm reasonably happy with how this works in practice (outside of the igt tests). Is the flexibility (of next_extension and separate bond structs) too much?
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 15/17] gem_wsim: Engine bond command
Quoted 32 lines · Chris Wilson
Quoting Tvrtko Ursulin (2018-10-18 16:28:13)
Quoted 31 lines
benchmarks/gem_wsim.c +20
-0@@ -1196,6 +1256,7 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) { .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE, .engines_mask = -1, }; +struct i915_context_engines_bond *bonds =NULL ;if (ctx->wants_balance) { set_engines.extensions =@@ -1211,7 +1272,31 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) ctx->engine_map[j] -VCS1 ;/* FIXME */ } +if (ctx->bond_count) { + bonds =calloc (ctx->bond_count,sizeof (*bonds)); + load_balance.base.next_extension = +to_user_pointer (&bonds[0 ]); + } + +for (j =0 ; j < ctx->bond_count; j++) { +struct i915_context_engines_bond *bond = + &bonds[j]; + +if (j < (ctx->bond_count -1 )) + bond->base.next_extension = +to_user_pointer (bond +1 ); + + bond->base.name =I915_CONTEXT_ENGINES_EXT_BOND ; + bond->master_class =I915_ENGINE_CLASS_VIDEO ; + bond->master_instance = + ctx->bonds[j].master -VCS1 ; + bond->sibling_mask = ctx->bonds[j].mask;
Quoted 8 lines
benchmarks/gem_wsim.c prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) · line 1299
Quoted 6 lines
benchmarks/gem_wsim.c +5
-0+ } +gem_context_set_param (fd, ¶m); + +if (bonds) +free (bonds);free(NULL) is legal, so just free(bonds) here.
The only one i am usually sure of is kfree. :)
Quoted 4 lines
Looking at how you have constructed the map for the extension, I'm reasonably happy with how this works in practice (outside of the igt tests). Is the flexibility (of
next_extensionand separate bond structs) too much?
Shrug. My only gripe is that it is a nice generic mechanism used only in ctx set param, which feels a bit on it's head (*), but in principle I think it is fine.
Regards,
Tvrtko
(*) Sounds like it would be nicer if it was a core concept in more of our uapi's. Going from the bottom up like create_context + extension this + extension that. And the same for other our ioctls, where applicable. But perhaps it is a stretch it would fit to many more places.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 16/17 gem_wsim: Some more example workloads
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
A few additional workloads useful for experimenting with scheduling.
--- benchmarks/wsim/frame-split-60fps.wsim | 16 ++++++++++++++++ benchmarks/wsim/high-composited-game.wsim | 11 +++++++++++ benchmarks/wsim/media-1080p-player.wsim | 5 +++++ benchmarks/wsim/medium-composited-game.wsim | 9 +++++++++ 4 files changed, 41 insertions(+) create mode 100644 benchmarks/wsim/frame-split-60fps.wsim create mode 100644 benchmarks/wsim/high-composited-game.wsim create mode 100644 benchmarks/wsim/media-1080p-player.wsim create mode 100644 benchmarks/wsim/medium-composited-game.wsim
benchmarks/wsim/frame-split-60fps.wsim new file +16 -0
@@ -0,0 +1,16 @@ +X.1.0 +M.1.VCS1 +B.1 +X.2.0 +M.2.VCS2 +B.2 +b.2.1.VCS1 +f +1.DEFAULT.4000-6000.f-1.0 +2.DEFAULT.4000-6000.s-1.0 +a.-3 +3.RCS.2000-4000.-3/-2.0 +3.VECS.2000.-1.0 +4.BCS.1000.-1.0 +s.-2 +p.16667
benchmarks/wsim/high-composited-game.wsim new file +11 -0
@@ -0,0 +1,11 @@ +1.RCS.500.0.0 +1.RCS.2000.0.0 +1.RCS.2000.0.0 +1.RCS.2000.0.0 +1.RCS.2000.0.0 +1.RCS.2000.0.0 +1.RCS.2000.0.0 +P.2.1 +2.BCS.1000.-2.0 +2.RCS.2000.-1.1 +p.16667
benchmarks/wsim/media-1080p-player.wsim new file +5 -0
@@ -0,0 +1,5 @@ +1.VCS.5000-10000.0.0 +2.RCS.1000-2000.-1.0 +P.3.1 +3.BCS.1000.-2.0 +p.16667
benchmarks/wsim/medium-composited-game.wsim new file +9 -0
@@ -0,0 +1,9 @@ +1.RCS.1000-2000.0.0 +1.RCS.1000-2000.0.0 +1.RCS.1000-2000.0.0 +1.RCS.1000-2000.0.0 +1.RCS.1000-2000.0.0 +P.2.1 +2.BCS.1000.-2.0 +2.RCS.2000.-1.1 +p.16667
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 17/17 gem_wsim: Infinite batch support
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
For simulating frame split workloads it is useful to express a batch which ends at the same time as the parallel submission on the respective bonded engine. For this we add support for infinite batch durations and the batch terminate command ('T'). Syntax looks like this:
1.RCS.*.0.0
T.-1
First step starts an infinite batch, and second command terminates the infinite batch with the usual relative workload step addressing.
--- benchmarks/gem_wsim.c | 119 +++++++++++++++++++------ benchmarks/wsim/README | 9 +- benchmarks/wsim/frame-split-60fps.wsim | 6 +- 3 files changed, 102 insertions(+), 32 deletions(-)
benchmarks/gem_wsim.c +91 -28
@@ -85,6 +85,7 @@ enum w_typeENGINE_MAP ,LOAD_BALANCE ,BOND , + TERMINATE, };struct deps
@@ -112,6 +113,7 @@ struct w_stepunsigned int context;unsigned int engine;struct duration duration; +bool unbound_duration;struct deps data_deps;struct deps fence_deps;int emit_fence;
@@ -142,7 +144,7 @@ struct w_stepstruct drm_i915_gem_execbuffer2 eb;struct drm_i915_gem_exec_object2 *obj; -struct drm_i915_gem_relocation_entry reloc[4 ]; +struct drm_i915_gem_relocation_entry reloc[5 ];unsigned long bb_sz;uint32_t bb_handle;uint32_t *mapped_batch;
@@ -153,6 +155,7 @@ struct w_stepuint32_t *rt1_address;uint32_t *latch_value;uint32_t *latch_address; +uint32_t *recursive_bb_start;unsigned int mapped_len; };
@@ -492,6 +495,10 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) step.type =ENGINE_MAP ; goto add_step; + }else if (!strcmp (field,"T" )) { +int_field (TERMINATE , target, + tmp >=0 || ((int )nr_steps + tmp) <0 , +"Invalid terminate target at step %u!\n" ); }else if (!strcmp (field,"X" )) {unsigned int nr =0 ;while ((field =strtok_r (fstart,"." , &fctx))) {
@@ -598,23 +605,28 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) fstart =NULL ; - tmpl =strtol (field, &sep,10 ); -check_arg (tmpl <=0 || tmpl ==LONG_MIN || - tmpl ==LONG_MAX , -"Invalid duration at step %u!\n" , nr_steps); - step.duration.min = tmpl; - -if (sep && *sep =='-' ) { - tmpl =strtol (sep +1 ,NULL ,10 ); -check_arg (tmpl <=0 || - tmpl <= step.duration.min || - tmpl ==LONG_MIN || +if (field[0 ] =='*' ) { + step.unbound_duration = true; + }else { + tmpl =strtol (field, &sep,10 ); +check_arg (tmpl <=0 || tmpl ==LONG_MIN || tmpl ==LONG_MAX , -"Invalid duration range at step %u!\n" , +"Invalid duration at step %u!\n" , nr_steps); - step.duration.max = tmpl; - }else { - step.duration.max = step.duration.min; + step.duration.min = tmpl; + +if (sep && *sep =='-' ) { + tmpl =strtol (sep +1 ,NULL ,10 ); +check_arg (tmpl <=0 || + tmpl <= step.duration.min || + tmpl ==LONG_MIN || + tmpl ==LONG_MAX , +"Invalid duration range at step %u!\n" , + nr_steps); + step.duration.max = tmpl; + }else { + step.duration.max = step.duration.min; + } } valid++;
@@ -773,7 +785,7 @@ init_bb(struct w_step *w, unsigned int flags)unsigned int i;uint32_t *ptr; -if (!arb_period) +if (w->unbound_duration || !arb_period)return ; gem_set_domain(fd, w->bb_handle,
@@ -793,6 +805,7 @@ terminate_bb(struct w_step *w, unsigned int flags)const uint32_t bbe =0xa <<23 ;unsigned long mmap_start, mmap_len;unsigned long batch_start = w->bb_sz; +unsigned int r =0 ;uint32_t *ptr, *cs;igt_assert (((flags &RT ) && (flags &SEQNO )) || !(flags &RT ));
@@ -803,6 +816,9 @@ terminate_bb(struct w_step *w, unsigned int flags)if (flags &RT ) batch_start -=12 *sizeof (uint32_t ); +if (w->unbound_duration) + batch_start -=4 *sizeof (uint32_t );/* MI_ARB_CHK + MI_BATCH_BUFFER_START */ + mmap_start =rounddown (batch_start,PAGE_SIZE ); mmap_len = w->bb_sz - mmap_start;
@@ -812,8 +828,19 @@ terminate_bb(struct w_step *w, unsigned int flags) ptr =gem_mmap__wc (fd, w->bb_handle, mmap_start, mmap_len,PROT_WRITE ); cs = (uint32_t *)((char *)ptr + batch_start - mmap_start); +if (w->unbound_duration) { + w->reloc[r++].offset = batch_start +2 *sizeof (uint32_t ); + batch_start +=4 *sizeof (uint32_t ); + + *cs++ = w->preempt_us ?0x5 <<23 /* MI_ARB_CHK; */ :MI_NOOP ; + w->recursive_bb_start = cs; + *cs++ =MI_BATCH_BUFFER_START |1 <<8 |1 ; + *cs++ =0 ; + *cs++ =0 ; + } +if (flags &SEQNO ) { - w->reloc[0 ].offset = batch_start +sizeof (uint32_t ); + w->reloc[r++].offset = batch_start +sizeof (uint32_t ); batch_start +=4 *sizeof (uint32_t ); *cs++ =MI_STORE_DWORD_IMM ;
@@ -825,7 +852,7 @@ terminate_bb(struct w_step *w, unsigned int flags) }if (flags &RT ) { - w->reloc[1 ].offset = batch_start +sizeof (uint32_t ); + w->reloc[r++].offset = batch_start +sizeof (uint32_t ); batch_start +=4 *sizeof (uint32_t ); *cs++ =MI_STORE_DWORD_IMM ;
@@ -835,7 +862,7 @@ terminate_bb(struct w_step *w, unsigned int flags) w->rt0_value = cs; *cs++ =0 ; - w->reloc[2 ].offset = batch_start +2 *sizeof (uint32_t ); + w->reloc[r++].offset = batch_start +2 *sizeof (uint32_t ); batch_start +=4 *sizeof (uint32_t ); *cs++ =0x24 <<23 |2 ;/* MI_STORE_REG_MEM */
@@ -844,7 +871,7 @@ terminate_bb(struct w_step *w, unsigned int flags) *cs++ =0 ; *cs++ =0 ; - w->reloc[3 ].offset = batch_start +sizeof (uint32_t ); + w->reloc[r++].offset = batch_start +sizeof (uint32_t ); batch_start +=4 *sizeof (uint32_t ); *cs++ =MI_STORE_DWORD_IMM ;
@@ -979,19 +1006,28 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags) } } - w->bb_sz =get_bb_sz (w->duration.max); - w->bb_handle = w->obj[j].handle =gem_create (fd, w->bb_sz); +if (w->unbound_duration) +/* nops + MI_ARB_CHK + MI_BATCH_BUFFER_START */ + w->bb_sz =max (64 ,get_bb_sz (w->preempt_us)) + + (1 +3 ) *sizeof (uint32_t ); +else + w->bb_sz =get_bb_sz (w->duration.max); + w->bb_handle = w->obj[j].handle =gem_create (fd, w->bb_sz + (w->unbound_duration ?4096 :0 ));init_bb (w, flags);terminate_bb (w, flags); -if (flags &SEQNO ) { +if ((flags &SEQNO ) || w->unbound_duration) { w->obj[j].relocs_ptr =to_user_pointer (&w->reloc); +if (flags &SEQNO ) + w->obj[j].relocation_count++;if (flags &RT ) - w->obj[j].relocation_count =4 ; -else - w->obj[j].relocation_count =1 ; + w->obj[j].relocation_count +=3 ; +if (w->unbound_duration) + w->obj[j].relocation_count++;for (i =0 ; i < w->obj[j].relocation_count; i++) w->reloc[i].target_handle =1 ; +if (w->unbound_duration) + w->reloc[0 ].target_handle = j; } w->eb.buffers_ptr =to_user_pointer (w->obj);
@@ -1988,6 +2024,18 @@ update_bb_rt(struct w_step *w, enum intel_engine_id engine, uint32_t seqno) } } +static void +update_bb_start (struct w_step *w) +{ +if (!w->unbound_duration) +return ; + +gem_set_domain (fd, w->bb_handle, +I915_GEM_DOMAIN_WC ,I915_GEM_DOMAIN_WC ); + + *w->recursive_bb_start =MI_BATCH_BUFFER_START | (1 <<8 ) |1 ; +} +static void w_sync_to (struct workload *wrk,struct w_step *w,int target) {if (target <0 )
@@ -2123,9 +2171,13 @@ do_eb(struct workload *wrk, struct w_step *w, enum intel_engine_id engine,if (flags &RT )update_bb_rt (w, engine, seqno); +update_bb_start (w); + w->eb.batch_start_offset = + w->unbound_duration ? +0 :ALIGN (w->bb_sz -get_bb_sz (get_duration (w)), -2 *sizeof (uint32_t )); +2 *sizeof (uint32_t ));for (i =0 ; i < w->fence_deps.nr; i++) {int tgt = w->idx + w->fence_deps.list[i];
@@ -2265,6 +2317,17 @@ static void *run_workload(void *data) w->priority; }continue ; + }else if (w->type ==TERMINATE ) { +unsigned int t_idx = i + w->target; + +igt_assert (t_idx >=0 && t_idx < i); +igt_assert (wrk->steps[t_idx].type ==BATCH ); +igt_assert (wrk->steps[t_idx].unbound_duration); + + *wrk->steps[t_idx].recursive_bb_start = +MI_BATCH_BUFFER_END ; +__sync_synchronize (); +continue ; } else if (w->type == PREEMPTION || w->type == ENGINE_MAP || w->type == LOAD_BALANCE ||
benchmarks/wsim/README +7 -2
@@ -2,11 +2,11 @@ Workload descriptor format ========================== ctx.engine.duration_us.dependency.wait,... -<uint>.<str>.<uint>[-<uint>].<int <= 0>[/<int <= 0>][...].<0|1>,... +<uint>.<str>.<uint>[-<uint>]|*.<int <= 0>[/<int <= 0>][...].<0|1>,... B.<uint> M.<uint>.<str>[|<str>]... P|X.<uint>.<int> -d|p|s|t|q|a.<int>,... +d|p|s|t|q|a|T.<int>,... b.<uint>.<uint>.<str> f
@@ -30,6 +30,7 @@ Additional workload steps are also supported: 'b' - Set up engine bonds. 'M' - Set up engine map. 'P' - Context priority. + 'T' - Terminate an infinite batch. 'X' - Context preemption control. Engine ids: DEFAULT, RCS, BCS, VCS, VCS1, VCS2, VECS
@@ -77,6 +78,10 @@ Example: I this case the last step has a data dependency on both first and second steps. +Batch durations can also be specified as infinite by using the '*' in the +duration field. Such batches must be ended by the terminate command ('T') +otherwise they will cause a GPU hang to be reported. + Sync (fd) fences ----------------
benchmarks/wsim/frame-split-60fps.wsim +4 -2
@@ -6,10 +6,12 @@ M.2.VCS2 B.2 b.2.1.VCS1 f -1.DEFAULT.4000-6000.f-1.0 +1.DEFAULT.*.f-1.0 2.DEFAULT.4000-6000.s-1.0 a.-3 -3.RCS.2000-4000.-3/-2.0 +s.-2 +T.-4 +3.RCS.2000-4000.-5/-4.0 3.VECS.2000.-1.0 4.BCS.1000.-1.0 s.-2
Signature · 6 lines
2.17.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for Media scalability tooling
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: Media scalability tooling
URL : https://patchwork.freedesktop.org/series/51193/
State : failure
== Summary ==
IGT patchset build failed on latest successful build 7766b1e2348b32cc8ed58a972c6fd53b20279549 tests/kms_selftest: Integrate kernel selftest test-drm_modeset
ninja: Entering directory `build'
[1/671] Generating version.h with a custom command.
[2/669] Linking static target lib/libigt-drmtest_c.a.
[3/669] Linking static target lib/libigt-i915_gem_context_c.a.
[4/669] Linking static target lib/libigt-i915_gem_scheduler_c.a.
[5/669] Linking static target lib/libigt-i915_gem_submission_c.a.
[6/669] Linking static target lib/libigt-i915_gem_ring_c.a.
[7/669] Linking static target lib/libigt-igt_debugfs_c.a.
[8/669] Linking static target lib/libigt-igt_device_c.a.
[9/669] Linking static target lib/libigt-igt_aux_c.a.
[10/669] Linking static target lib/libigt-igt_gt_c.a.
[11/669] Linking static target lib/libigt-igt_syncobj_c.a.
[12/669] Linking static target lib/libigt-igt_sysfs_c.a.
[13/669] Linking static target lib/libigt-igt_vgem_c.a.
[14/669] Linking static target lib/libigt-intel_batchbuffer_c.a.
[15/669] Linking static target lib/libigt-intel_chipset_c.a.
[16/669] Linking static target lib/libigt-intel_mmio_c.a.
[17/669] Linking static target lib/libigt-ioctl_wrappers_c.a.
[18/669] Linking static target lib/libigt-media_spin_c.a.
[19/669] Linking static target lib/libigt-media_fill_c.a.
[20/669] Linking static target lib/libigt-gpgpu_fill_c.a.
[21/669] Linking static target lib/libigt-gpu_cmds_c.a.
[22/669] Linking static target lib/libigt-rendercopy_i915_c.a.
[23/669] Linking static target lib/libigt-rendercopy_i830_c.a.
[24/669] Linking static target lib/libigt-rendercopy_gen4_c.a.
[25/669] Linking static target lib/libigt-rendercopy_gen6_c.a.
[26/669] Linking static target lib/libigt-rendercopy_gen7_c.a.
[27/669] Linking static target lib/libigt-rendercopy_gen8_c.a.
[28/669] Linking static target lib/libigt-rendercopy_gen9_c.a.
[29/669] Compiling C object 'lib/igt-sw_sync_c@sta/sw_sync.c.o'.
FAILED: lib/igt-sw_sync_c@sta/sw_sync.c.o
ccache cc -Ilib/igt-sw_sync_c@sta -Ilib -I../lib -I. -I../ -I../lib/stubs/syscalls -I../include/drm-uapi -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/igt/include -I/opt/igt/include/libdrm -I/usr/include/x86_64-linux-gnu -I/usr/include -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -D_GNU_SOURCE -include config.h -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-clobbered -Wno-type-limits -Wimplicit-fallthrough=0 -fPIC -pthread '-DIGT_DATADIR="/opt/igt/share/igt-gpu-tools"' '-DIGT_SRCDIR="/home/cidrm/igt-gpu-tools/tests"' '-DIGT_LOG_DOMAIN="sw_sync"' -MD -MQ 'lib/igt-sw_sync_c@sta/sw_sync.c.o' -MF 'lib/igt-sw_sync_c@sta/sw_sync.c.o.d' -o 'lib/igt-sw_sync_c@sta/sw_sync.c.o' -c ../lib/sw_sync.c ../lib/sw_sync.c:36:10: fatal error: sync_file.h: No such file or directory
#include "sync_file.h"
^~~~~~~~~~~~~compilation terminated.
ninja: build stopped: subcommand failed.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev