Add crc32 calculation on dg2 gpu
Subsystems (2)
cover Add crc32 calculation on dg2 gpu
Add crc32 calculation library on gpu (dg2).
v2: use predication instead of cond_bbe with memory access.
v3: migrate crc32 tables to separate file to avoid license clashes.
v4: move common definitions to intel_reg.h, add docs
Zbigniew Kempczyński (4):
lib/intel_reg: Add common MI_* macros to remove duplicates lib/igt_crc: Introduce common place for crc tables and functions lib/i915_crc: Introduce crc32 on gpu for DG2 tests/api_intel_bb: Add crc32 checking test for DG2
benchmarks/gem_wsim.c | 34 +- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 2 + lib/i915/i915_crc.c | 297 ++++++++++++++++++ lib/i915/i915_crc.h | 27 ++ lib/igt_crc.c | 107 +++++++ lib/igt_crc.h | 31 ++ lib/intel_reg.h | 45 +++ lib/meson.build | 2 + tests/i915/api_intel_bb.c | 69 ++++ tests/i915/gem_exec_fair.c | 27 -- tests/i915/gem_exec_fence.c | 31 -- tests/i915/gem_watchdog.c | 27 -- tests/i915/gem_workarounds.c | 7 +- tests/i915/gen7_exec_parse.c | 8 +- tests/i915/gen9_exec_parse.c | 11 +- 15 files changed, 595 insertions(+), 130 deletions(-) create mode 100644 lib/i915/i915_crc.c create mode 100644 lib/i915/i915_crc.h create mode 100644 lib/igt_crc.c create mode 100644 lib/igt_crc.h
Signature · 1 line
2.32.0
PATCH 1/4 lib/intel_reg: Add common MI_* macros to remove duplicates
In few tests we got some MI_* duplicates (MI_MATH for example). Add common definitions in intel_reg.h and remove local definitions in the tests.
--- benchmarks/gem_wsim.c | 34 ++++------------------------- lib/intel_reg.h | 42 ++++++++++++++++++++++++++++++++++++ tests/i915/gem_exec_fair.c | 27 ----------------------- tests/i915/gem_exec_fence.c | 31 -------------------------- tests/i915/gem_watchdog.c | 27 ----------------------- tests/i915/gem_workarounds.c | 7 +++--- tests/i915/gen7_exec_parse.c | 8 +++---- tests/i915/gen9_exec_parse.c | 11 ++++------ 8 files changed, 57 insertions(+), 130 deletions(-)
benchmarks/gem_wsim.c +4 -30
@@ -279,36 +279,7 @@ static uint64_t ns_to_ctx_ticks(uint64_t ns)return div64_u64_round_up (ns * f,NSEC_PER_SEC ); } -#define MI_INSTR (opcode, flags) (((opcode) << 23) | (flags)) - -#define MI_ARB_CHECK MI_INSTR(0x5, 0) - -#define MI_MATH (x) MI_INSTR(0x1a, (x) - 1) -#define MI_MATH_INSTR (opcode, op1, op2) ((opcode) << 20 | (op1) << 10 | (op2)) -/* Opcodes for MI_MATH_INSTR */ -#define MI_MATH_NOOP MI_MATH_INSTR(0x000, 0x0, 0x0) -#define MI_MATH_LOAD (op1, op2) MI_MATH_INSTR(0x080, op1, op2) -#define MI_MATH_LOADINV (op1, op2) MI_MATH_INSTR(0x480, op1, op2) -#define MI_MATH_LOAD0 (op1) MI_MATH_INSTR(0x081, op1) -#define MI_MATH_LOAD1 (op1) MI_MATH_INSTR(0x481, op1) -#define MI_MATH_ADD MI_MATH_INSTR(0x100, 0x0, 0x0) -#define MI_MATH_SUB MI_MATH_INSTR(0x101, 0x0, 0x0) -#define MI_MATH_AND MI_MATH_INSTR(0x102, 0x0, 0x0) -#define MI_MATH_OR MI_MATH_INSTR(0x103, 0x0, 0x0) -#define MI_MATH_XOR MI_MATH_INSTR(0x104, 0x0, 0x0) -#define MI_MATH_STORE (op1, op2) MI_MATH_INSTR(0x180, op1, op2) -#define MI_MATH_STOREINV (op1, op2) MI_MATH_INSTR(0x580, op1, op2) -/* Registers used as operands in MI_MATH_INSTR */ -#define MI_MATH_REG (x) (x) -#define MI_MATH_REG_SRCA 0x20 -#define MI_MATH_REG_SRCB 0x21 -#define MI_MATH_REG_ACCU 0x31 -#define MI_MATH_REG_ZF 0x32 -#define MI_MATH_REG_CF 0x33 -#define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1) -#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 0) -#define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 1)#define MI_CS_MMIO_DST BIT(19)#define MI_CS_MMIO_SRC BIT(18)
@@ -1487,7 +1458,10 @@ static unsigned int create_bb(struct w_step *w, int self) *cs++ =MI_MATH_STOREINV (MI_MATH_REG (NOW_TS ),MI_MATH_REG_ACCU );/* Save delta for indirect read by COND_BBE */ - *cs++ =MI_STORE_REGISTER_MEM | (1 + use_64b) |MI_CS_MMIO_DST ; +if (use_64b) + *cs++ =MI_STORE_REGISTER_MEM_GEN8 |MI_CS_MMIO_DST ; +else + *cs++ =MI_STORE_REGISTER_MEM |MI_CS_MMIO_DST ; *cs++ =CS_GPR (NOW_TS ); w->reloc[r].target_handle = self; w->reloc[r].offset =offset_in_page (cs);
lib/intel_reg.h +42 -0
66 lines not on this page · raw message
tests/i915/gem_exec_fair.c +0 -27
@@ -112,33 +112,6 @@ static uint64_t ticks_to_ns(int i915, uint64_t ticks) read_timestamp_frequency(i915)); } -#define MI_INSTR (opcode, flags) (((opcode) << 23) | (flags)) - -#define MI_MATH (x) MI_INSTR(0x1a, (x) - 1) -#define MI_MATH_INSTR (opcode, op1, op2) ((opcode) << 20 | (op1) << 10 | (op2)) -/* Opcodes for MI_MATH_INSTR */ -#define MI_MATH_NOOP MI_MATH_INSTR(0x000, 0x0, 0x0) -#define MI_MATH_LOAD (op1, op2) MI_MATH_INSTR(0x080, op1, op2) -#define MI_MATH_LOADINV (op1, op2) MI_MATH_INSTR(0x480, op1, op2) -#define MI_MATH_LOAD0 (op1) MI_MATH_INSTR(0x081, op1) -#define MI_MATH_LOAD1 (op1) MI_MATH_INSTR(0x481, op1) -#define MI_MATH_ADD MI_MATH_INSTR(0x100, 0x0, 0x0) -#define MI_MATH_SUB MI_MATH_INSTR(0x101, 0x0, 0x0) -#define MI_MATH_AND MI_MATH_INSTR(0x102, 0x0, 0x0) -#define MI_MATH_OR MI_MATH_INSTR(0x103, 0x0, 0x0) -#define MI_MATH_XOR MI_MATH_INSTR(0x104, 0x0, 0x0) -#define MI_MATH_STORE (op1, op2) MI_MATH_INSTR(0x180, op1, op2) -#define MI_MATH_STOREINV (op1, op2) MI_MATH_INSTR(0x580, op1, op2) -/* Registers used as operands in MI_MATH_INSTR */ -#define MI_MATH_REG (x) (x) -#define MI_MATH_REG_SRCA 0x20 -#define MI_MATH_REG_SRCB 0x21 -#define MI_MATH_REG_ACCU 0x31 -#define MI_MATH_REG_ZF 0x32 -#define MI_MATH_REG_CF 0x33 - -#define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 1) - static void delay(int i915, const struct intel_execution_engine2 *e, uint32_t handle,
tests/i915/gem_exec_fence.c +0 -31
@@ -2366,37 +2366,6 @@ static void test_syncobj_timeline_multiple_ext_nodes(int fd)syncobj_destroy (fd, syncobjs[i]); } -#define MI_INSTR (opcode, flags) (((opcode) << 23) | (flags)) - -/* #define MI_LOAD_REGISTER_MEM (MI_INSTR(0x29, 1) */ -/* #define MI_LOAD_REGISTER_MEM_GEN8 MI_INSTR(0x29, 2) */ - -#define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 1) - -#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1) -#define MI_STORE_REGISTER_MEM_GEN8 MI_INSTR(0x24, 2) - -#define MI_MATH (x) MI_INSTR(0x1a, (x) - 1) -#define MI_MATH_INSTR (opcode, op1, op2) ((opcode) << 20 | (op1) << 10 | (op2)) -/* Opcodes for MI_MATH_INSTR */ -#define MI_MATH_NOOP MI_MATH_INSTR(0x00, 0x0, 0x0) -#define MI_MATH_LOAD (op1, op2) MI_MATH_INSTR(0x80, op1, op2) -#define MI_MATH_LOADINV (op1, op2) MI_MATH_INSTR(0x480, op1, op2) -#define MI_MATH_ADD MI_MATH_INSTR(0x100, 0x0, 0x0) -#define MI_MATH_SUB MI_MATH_INSTR(0x101, 0x0, 0x0) -#define MI_MATH_AND MI_MATH_INSTR(0x102, 0x0, 0x0) -#define MI_MATH_OR MI_MATH_INSTR(0x103, 0x0, 0x0) -#define MI_MATH_XOR MI_MATH_INSTR(0x104, 0x0, 0x0) -#define MI_MATH_STORE (op1, op2) MI_MATH_INSTR(0x180, op1, op2) -#define MI_MATH_STOREINV (op1, op2) MI_MATH_INSTR(0x580, op1, op2) -/* Registers used as operands in MI_MATH_INSTR */ -#define MI_MATH_REG (x) (x) -#define MI_MATH_REG_SRCA 0x20 -#define MI_MATH_REG_SRCB 0x21 -#define MI_MATH_REG_ACCU 0x31 -#define MI_MATH_REG_ZF 0x32 -#define MI_MATH_REG_CF 0x33 -#define HSW_CS_GPR (n) (0x600 + 8*(n))#define RING_TIMESTAMP (0x358)#define MI_PREDICATE_RESULT_1 (0x41c)
tests/i915/gem_watchdog.c +0 -27
@@ -270,33 +270,6 @@ static void virtual(int i915, const intel_ctx_cfg_t *base_cfg)igt_assert_eq (count, expect); } -#define MI_INSTR (opcode, flags) (((opcode) << 23) | (flags)) - -#define MI_MATH (x) MI_INSTR(0x1a, (x) - 1) -#define MI_MATH_INSTR (opcode, op1, op2) ((opcode) << 20 | (op1) << 10 | (op2)) -/* Opcodes for MI_MATH_INSTR */ -#define MI_MATH_NOOP MI_MATH_INSTR(0x000, 0x0, 0x0) -#define MI_MATH_LOAD (op1, op2) MI_MATH_INSTR(0x080, op1, op2) -#define MI_MATH_LOADINV (op1, op2) MI_MATH_INSTR(0x480, op1, op2) -#define MI_MATH_LOAD0 (op1) MI_MATH_INSTR(0x081, op1) -#define MI_MATH_LOAD1 (op1) MI_MATH_INSTR(0x481, op1) -#define MI_MATH_ADD MI_MATH_INSTR(0x100, 0x0, 0x0) -#define MI_MATH_SUB MI_MATH_INSTR(0x101, 0x0, 0x0) -#define MI_MATH_AND MI_MATH_INSTR(0x102, 0x0, 0x0) -#define MI_MATH_OR MI_MATH_INSTR(0x103, 0x0, 0x0) -#define MI_MATH_XOR MI_MATH_INSTR(0x104, 0x0, 0x0) -#define MI_MATH_STORE (op1, op2) MI_MATH_INSTR(0x180, op1, op2) -#define MI_MATH_STOREINV (op1, op2) MI_MATH_INSTR(0x580, op1, op2) -/* Registers used as operands in MI_MATH_INSTR */ -#define MI_MATH_REG (x) (x) -#define MI_MATH_REG_SRCA 0x20 -#define MI_MATH_REG_SRCB 0x21 -#define MI_MATH_REG_ACCU 0x31 -#define MI_MATH_REG_ZF 0x32 -#define MI_MATH_REG_CF 0x33 - -#define MI_LOAD_REGISTER_REG MI_INSTR(0x2A, 1) -static unsigned int offset_in_page (void *addr) {return (uintptr_t )addr &4095 ;
tests/i915/gem_workarounds.c +4 -3
@@ -83,8 +83,6 @@ static bool write_only(const uint32_t addr)return false; } -#define MI_STORE_REGISTER_MEM (0x24 << 23) -static int workaround_fail_count (int i915,const intel_ctx_t *ctx) {struct drm_i915_gem_exec_object2 obj[2 ];
@@ -122,7 +120,10 @@ static int workaround_fail_count(int i915, const intel_ctx_t *ctx) out = base =gem_mmap__cpu (i915, obj[1 ].handle,0 , batch_sz,PROT_WRITE );for (int i =0 ; i < num_wa_regs; i++) { - *out++ =MI_STORE_REGISTER_MEM | ((gen >=8 ?4 :2 ) -2 ); +if (gen >=8 ) + *out++ =MI_STORE_REGISTER_MEM_GEN8 ; +else + *out++ =MI_STORE_REGISTER_MEM ; *out++ = wa_regs[i].addr; reloc[i].target_handle = obj[0 ].handle; reloc[i].offset = (out - base) *sizeof (*out);
tests/i915/gen7_exec_parse.c +3 -5
@@ -48,8 +48,6 @@#define INSTR_CLIENT_SHIFT 29#define INSTR_INVALID_CLIENT 0x7 -#define MI_LOAD_REGISTER_REG (0x2a << 23) -#define MI_STORE_REGISTER_MEM (0x24 << 23)#define MI_ARB_ON_OFF (0x8 << 23)#define MI_DISPLAY_FLIP ((0x14 << 23) | 1)
@@ -374,19 +372,19 @@ static void test_allocations(int fd)static void hsw_load_register_reg (void ) {uint32_t init_gpr0[16 ] = { -MI_LOAD_REGISTER_IMM | (3 -2 ), +MI_LOAD_REGISTER_IMM ,HSW_CS_GPR0 ,0xabcdabc0 ,/* leave [1:0] zero */ MI_BATCH_BUFFER_END , };uint32_t store_gpr0[16 ] = { -MI_STORE_REGISTER_MEM | (3 -2 ), +MI_STORE_REGISTER_MEM ,HSW_CS_GPR0 ,0 ,/* reloc*/ MI_BATCH_BUFFER_END , };uint32_t do_lrr[16 ] = { -MI_LOAD_REGISTER_REG | (3 -2 ), +MI_LOAD_REGISTER_REG ,0 ,/* [1] = src */ HSW_CS_GPR0 ,/* dst */ MI_BATCH_BUFFER_END ,
tests/i915/gen9_exec_parse.c +4 -7
@@ -38,12 +38,9 @@#define INSTR_CLIENT_SHIFT 29#define INSTR_INVALID_CLIENT 0x7 -#define MI_LOAD_REGISTER_REG (0x2a << 23) -#define MI_STORE_REGISTER_MEM (0x24 << 23)#define MI_ARB_ON_OFF (0x8 << 23)#define MI_USER_INTERRUPT (0x02 << 23)#define MI_FLUSH_DW (0x26 << 23) -#define MI_ARB_CHECK (0x05 << 23)#define MI_REPORT_HEAD (0x07 << 23)#define MI_SUSPEND_FLUSH (0x0b << 23)#define MI_LOAD_SCAN_LINES_EXCL (0x13 << 23)
@@ -689,7 +686,7 @@ static void test_cmd_crossing_page(const int i915, const uint32_t handle) MI_BATCH_BUFFER_END, };const uint32_t store_reg[] = { -MI_STORE_REGISTER_MEM | (4 -2 ), +MI_STORE_REGISTER_MEM_GEN8 ,BCS_GPR (0 ),0 ,/* reloc */ 0 ,/* reloc */
@@ -728,7 +725,7 @@ static void test_invalid_length(const int i915, const uint32_t handle) };const uint32_t store_reg[] = { -MI_STORE_REGISTER_MEM | (4 -2 ), +MI_STORE_REGISTER_MEM_GEN8 ,BCS_GPR (0 ),0 ,/* reloc */ 0 ,/* reloc */
@@ -841,7 +838,7 @@ static void test_register(const int i915, const uint32_t handle, };const uint32_t store_reg[] = { -MI_STORE_REGISTER_MEM | (4 -2 ), +MI_STORE_REGISTER_MEM_GEN8 , r->addr,0 ,/* reloc */ 0 ,/* reloc */
@@ -880,7 +877,7 @@ static long int read_reg(const int i915, const uint32_t handle, const uint32_t addr) {const uint32_t store_reg[] = { -MI_STORE_REGISTER_MEM | (4 -2 ), +MI_STORE_REGISTER_MEM_GEN8 , addr,0 ,/* reloc */ 0 ,/* reloc */
Signature · 1 line
2.32.0
PATCH 2/4 lib/igt_crc: Introduce common place for crc tables and functions
In reply to Zbigniew KempczyńskiAdd crc32 table for on-cpu crc calculation function. Other tables and algorithms should be added here allowing reuse tables for in-gpu crc calculation.
--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/igt_crc.c | 107 ++++++++++++++++++ lib/igt_crc.h | 31 +++++ lib/meson.build | 1 + 4 files changed, 140 insertions(+) create mode 100644 lib/igt_crc.c create mode 100644 lib/igt_crc.h
docs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1 -0
@@ -22,6 +22,7 @@ <xi:include href="xml/igt_chamelium.xml"/> <xi:include href="xml/igt_collection.xml"/> <xi:include href="xml/igt_core.xml"/> + <xi:include href="xml/igt_crc.xml"/> <xi:include href="xml/igt_debugfs.xml"/> <xi:include href="xml/igt_device.xml"/> <xi:include href="xml/igt_device_scan.xml"/>
lib/igt_crc.c new file +107 -0
107 lines not on this page · raw message
lib/igt_crc.h new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2022 Intel Corporation +*/ + +#ifndef __IGT_CRC_H__ +#define __IGT_CRC_H__ + +#include <stddef.h> +#include <stdint.h> + +/** +* SECTION:igt_crc +* @short_description: igt crc tables and calculation functions +* @title: CRC +* @include: igt_crc.h +* +* # Introduction +* +* Providing vendor agnostic crc calculation is useful to avoid code +* duplication. Especially if vendor will decide to do on-gpu crc calculation +* it will need to inject crc table to gpu. +* +* All crc tables are globals to allow direct in-code use. +*/ + +const uint32_t igt_crc32_tab[256 ]; + +uint32_t igt_cpu_crc32 (const void *buf,size_t size); + +#endif
lib/meson.build +1 -0
@@ -15,6 +15,7 @@ lib_sources = [ 'i915/i915_blt.c', 'igt_collection.c', 'igt_color_encoding.c', + 'igt_crc.c', 'igt_debugfs.c', 'igt_device.c', 'igt_device_scan.c',
Signature · 1 line
2.32.0
PATCH 3/4 lib/i915_crc: Introduce crc32 on gpu for DG2
In reply to Zbigniew KempczyńskiAdding crc32 calculation on gpu gives us new possibility to verify data integrity without relying on trust cpu mapping is correct.
Patch introduces calculating crc32 on DG2 only. On older gens ALU (MI_MATH) doesn't support bit-shifting instructions as well as multiply or divide. Emulating n-bit shifts cost hundred of instructions with predicated SRM (works on render engine only). Another limitation is lack of indexed load / store. On DG2 we can use WPARID and CS_MI_ADDRESS_OFFSET to achieve indexed operation on memory.
Due to performance reasons (cpu crc32 calculation even on WC memory is still much faster than on gpu, also depends on calculated object memory region) calculation will complete in reasonable of time only for few MiB.
v2: - use registers relative to engine to allow run on all engines (Chris)
- use predication instead of memory access to get better performance (Chris)
- add location where crc32 implementation comes from (Petri)
v4: - use common crc32 table from igt_crc
- add docs
--- .../igt-gpu-tools/igt-gpu-tools-docs.xml | 1 + lib/i915/i915_crc.c | 297 ++++++++++++++++++ lib/i915/i915_crc.h | 27 ++ lib/intel_reg.h | 3 + lib/meson.build | 1 + 5 files changed, 329 insertions(+) create mode 100644 lib/i915/i915_crc.c create mode 100644 lib/i915/i915_crc.h
docs/reference/igt-gpu-tools/igt-gpu-tools-docs.xml +1 -0
@@ -63,6 +63,7 @@ <xi:include href="xml/gem_scheduler.xml"/> <xi:include href="xml/gem_submission.xml"/> <xi:include href="xml/i915_blt.xml"/> + <xi:include href="xml/i915_crc.xml"/> <xi:include href="xml/intel_ctx.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>
lib/i915/i915_crc.c new file +297 -0
297 lines not on this page · raw message
lib/i915/i915_crc.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2022 Intel Corporation +*/ +#ifndef _I915_CRC_H_ +#define _I915_CRC_H_ + +#include <stdint.h> +#include "intel_ctx.h" + +/** +* SECTION:i915_crc +* @short_description: i915 gpu crc +* @title: I915 GPU CRC +* @include: i915_crc.h +* +* # Introduction +* +* Intel gpu crc calculation implementation. +*/ + +uint32_t i915_crc32 (int i915,uint64_t ahnd,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e, +uint32_t data_handle,uint32_t data_size); +bool supports_i915_crc32 (int i915); + +#endif /* _I915_CRC_ */
lib/intel_reg.h +3 -0
@@ -2704,6 +2704,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#define MI_MATH_REG_ZF 0x32#define MI_MATH_REG_CF 0x33 +/* DG2+ */ +#define MI_SET_PREDICATE MI_INSTR(0x1, 0) +#define MAX_DISPLAY_PIPES 2 typedef enum {
lib/meson.build +1 -0
@@ -13,6 +13,7 @@ lib_sources = [ 'i915/intel_memory_region.c', 'i915/intel_mocs.c', 'i915/i915_blt.c', + 'i915/i915_crc.c', 'igt_collection.c', 'igt_color_encoding.c', 'igt_crc.c',
Signature · 1 line
2.32.0
PATCH 4/4 tests/api_intel_bb: Add crc32 checking test for DG2
In reply to Zbigniew KempczyńskiAdd simple test which compares crc32 sums and calculation times on cpu and gpu.
--- tests/i915/api_intel_bb.c | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
tests/i915/api_intel_bb.c +69 -0
@@ -22,6 +22,7 @@*/ #include "igt.h" +#include "igt_crc.h" #include "i915/gem.h" #include "i915/gem_create.h" #include <unistd.h>
@@ -38,6 +39,7 @@#include <zlib.h> #include "intel_bufops.h" #include "i915/gem_vm.h" +#include "i915/i915_crc.h" #define PAGE_SIZE 4096
@@ -1395,6 +1397,57 @@ static void render_ccs(struct buf_ops *bops)igt_assert_f (fails ==0 ,"render-ccs fails: %d\n" , fails); } +static double elapsed (const struct timeval *start, +const struct timeval *end) +{ +return (1e6 *(end->tv_sec - start->tv_sec) + (end->tv_usec - start->tv_usec)) /1e6 ; +} + +static void test_crc32 (int i915,const intel_ctx_t *ctx, +const struct intel_execution_engine2 *e, +struct drm_i915_gem_memory_class_instance *r) +{ +uint64_t ahnd =get_reloc_ahnd (i915, ctx->id); +uint32_t data, *ptr; + +uint32_t region =INTEL_MEMORY_REGION_ID (r->memory_class, + r->memory_instance); + +igt_info ("[engine: %s, region: %s]\n" , e->name, + region ==REGION_SMEM ?"smem" :"lmem" ); +for (int i =12 ; i <21 ; i++) { +struct timeval start, end; +uint64_t size =1 << i; +uint32_t cpu_crc, gpu_crc; + +double cpu_time, gpu_time; + + data =gem_create_in_memory_regions (i915, size, region); + ptr =gem_mmap__device_coherent (i915, data,0 , size,PROT_WRITE ); +for (int j =0 ; j < size /sizeof (*ptr); j++) + ptr[j] = j; + +gettimeofday (&start,NULL ); + cpu_crc =igt_cpu_crc32 (ptr, size); +gettimeofday (&end,NULL ); + cpu_time =elapsed (&start, &end); + +gettimeofday (&start,NULL ); + gpu_crc =i915_crc32 (i915, ahnd, ctx, e, data, size); +gettimeofday (&end,NULL ); + gpu_time =elapsed (&start, &end); +igt_info ("size: %10lld, cpu crc: 0x%08x (time: %.3f), " +"gpu crc: 0x%08x (time: %.3f) [ %s ]\n" , + (long long ) size, cpu_crc, cpu_time, gpu_crc, gpu_time, + cpu_crc == gpu_crc ?"EQUAL" :"DIFFERENT" ); +munmap (ptr, size); +gem_close (i915, data); +igt_assert (cpu_crc == gpu_crc); + } + +put_ahnd (ahnd); +} +static int opt_handler (int opt,int opt_index,void *data) {switch (opt) {
@@ -1552,6 +1605,22 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL) igt_subtest("render-ccs")render_ccs (bops); +igt_describe ("Compare cpu and gpu crc32 sums on input object" ); + igt_subtest_with_dynamic_f("crc32") { +const intel_ctx_t *ctx; +const struct intel_execution_engine2 *e; + +igt_require (supports_i915_crc32 (i915)); + + ctx =intel_ctx_create_all_physical (i915); +for_each_ctx_engine (i915, ctx, e) { +for_each_memory_region (r, i915) { + igt_dynamic_f("%s-%s", e->name, r->name) +test_crc32 (i915, ctx, e, &r->ci); + } + } + } + igt_fixture {buf_ops_destroy (bops);close (i915);
Signature · 1 line
2.32.0