stvec a vector instruction extension for high performance
play

StVEC: A Vector Instruction Extension for High Performance Stencil - PowerPoint PPT Presentation

StVEC: A Vector Instruction Extension for High Performance Stencil Computation Renji Thomas Louis-No el Pouchet Naser Sedaghati Radu Teodorescu P. Sadayappan Department of Computer Science and Engineering The Ohio State University HPC


  1. StVEC: A Vector Instruction Extension for High Performance Stencil Computation Renji Thomas Louis-No¨ el Pouchet Naser Sedaghati Radu Teodorescu P. Sadayappan Department of Computer Science and Engineering The Ohio State University HPC Research Lab: barista.cse.ohio-state.edu Computer Architecture Lab: arch.cse.ohio-state.edu October 13 th 2011 Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 1 / 24

  2. Outline Introduction 1 Vectorization of Stencils 2 Enhancing Vector ISA with StVEC 3 Generating Code for StVEC 4 Evaluation 5 Summary 6 Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 2 / 24

  3. Introduction Stencil Computation Repeat over TIME Sweep over a spatial grid Compute a point from neighbor points values Same grid or multiple grids Numerous application domains Finite difference methods for solving PDEs Image processing (e.g. MRI image pipeline) Computational electromagnetics, CFD, numerical relativity, etc. Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 3 / 24

  4. Introduction Stencil Computation: An Example 2-D 5-point Jacobi for (t = 0; t < TMAX; t++) for (i = 1; i < N - 1; i++) for (j = 1; j < M - 1; j++) B[i][j] = A[i-1][j] + A[i][j-1] + A[i ][j] + A[i][j+1] + A[i+1][j]; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 4 / 24

  5. Introduction Stencil Computation: An Example 2-D 5-point Jacobi for (t = 0; t < TMAX; t++) for (i = 1; i < N - 1; i++) for (j = 1; j < M - 1; j++) B[i][j] = A[i-1][j] + A[i][j-1] + A[i ][j] + A[i][j+1] + A[i+1][j]; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 4 / 24

  6. Introduction Stencil Computation: An Example 2-D 5-point Jacobi for (t = 0; t < TMAX; t++) for (i = 1; i < N - 1; i++) for (j = 1; j < M - 1; j++) B[i][j] = A[i-1][j] + A[i][j-1] + A[i ][j] + A[i][j+1] + A[i+1][j]; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 4 / 24

  7. Introduction Stencil Computation: An Example 2-D 5-point Jacobi for (t = 0; t < TMAX; t++) for (i = 1; i < N - 1; i++) for (j = 1; j < M - 1; j++) B[i][j] = A[i-1][j] + A[i][j-1] + A[i ][j] + A[i][j+1] + A[i+1][j]; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 4 / 24

  8. Introduction Short-Vector SIMD Identical computation on small chunks of data Independent operations Vector size (width) of 2 to 64 Packing operations to form a vector (shuffle, extract, etc.) SIMD performance Multiple SIMD units per CPU Maximum speedup equals the vector width Ubiquitous features on modern processors x86 – SSE, AVX Power – VMX/VSX ARM – NEON Cell SPU Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 5 / 24

  9. Introduction Vectorization: An Example Vector width = 4, N divisible by 4 for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] = B[i] * B[i] ; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 6 / 24

  10. Introduction Vectorization: An Example Vector width = 4, N divisible by 4 for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] = B[i] * B[i] ; 1: ASM (MIPS-like) for (t = 0; t < T; t++) for (i = 4; i < N; i++){ LD R1, &B[i] MUL R2, R1, R1 ST R2, &A[i] } Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 6 / 24

  11. Introduction Vectorization: An Example Vector width = 4, N divisible by 4 for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] = B[i] * B[i] ; 1: ASM (MIPS-like) 2: 4-way unroll + re-schedule for (t = 0; t < T; t++) for (t = 0; t < T; t++) for (i = 4; i < N; i++){ for (i = 4; i < N; i+=4){ LD R1, &B[i] LD R1, &B[i] MUL R2, R1, R1 LD R2, &B[i+1] LD R3, &B[i+2] ST R2, &A[i] LD R4, &B[i+3] } MUL R5, R1, R1 MUL R6, R2, R2 MUL R7, R3, R3 MUL R8, R4, R4 ST R5, &A[i] ST R6, &A[i+1] ST R7, &A[i+2] ST R8, &A[i+3] } Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 6 / 24

  12. Introduction Vectorization: An Example Vector width = 4, N divisible by 4 for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] = B[i] * B[i] ; 1: ASM (MIPS-like) 2: 4-way unroll + re-schedule 3: Vectorize for (t = 0; t < T; t++) for (t = 0; t < T; t++) for (t = 0; t < T; t++) for (i = 4; i < N; i+=4){ for (i = 4; i < N; i++){ for (i = 4; i < N; i+=4){ VLD VR1, &B[i] LD R1, &B[i] LD R1, &B[i] VMUL VR2, VR1, VR1 MUL R2, R1, R1 LD R2, &B[i+1] VST VR2, &A[i] LD R3, &B[i+2] ST R2, &A[i] } LD R4, &B[i+3] } MUL R5, R1, R1 MUL R6, R2, R2 MUL R7, R3, R3 MUL R8, R4, R4 ST R5, &A[i] ST R6, &A[i+1] ST R7, &A[i+2] ST R8, &A[i+3] } Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 6 / 24

  13. Introduction Vectorization: An Example Vector width = 4, N divisible by 4 for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] = B[i] * B[i] ; 1: ASM (MIPS-like) 2: 4-way unroll + re-schedule 3: Vectorize for (t = 0; t < T; t++) for (t = 0; t < T; t++) for (t = 0; t < T; t++) for (i = 4; i < N; i+=4){ for (i = 4; i < N; i++){ for (i = 4; i < N; i+=4){ VLD VR1, &B[i] LD R1, &B[i] LD R1, &B[i] VMUL VR2, VR1, VR1 MUL R2, R1, R1 LD R2, &B[i+1] VST VR2, &A[i] LD R3, &B[i+2] ST R2, &A[i] } LD R4, &B[i+3] } MUL R5, R1, R1 MUL R6, R2, R2 MUL R7, R3, R3 MUL R8, R4, R4 ST R5, &A[i] ST R6, &A[i+1] ST R7, &A[i+2] ST R8, &A[i+3] } Observation Aligned memory referencing (i.e. B[i]) helps vectorization! Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 6 / 24

  14. Vectorization of Stencils Vectorization of Stencils Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 7 / 24

  15. Vectorization of Stencils Vectorizing Stencil Computation for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] += B[i-1] * B[i]; Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 8 / 24

  16. Vectorization of Stencils Vectorizing Stencil Computation for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] += B[i-1] * B[i]; Solution1: load + shuffle B[ ] in XMM Registers SSE Assembly (N=1024) Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 8 / 24

  17. Vectorization of Stencils Vectorizing Stencil Computation for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] += B[i-1] * B[i]; Solution1: load + shuffle Solution2: unaligned load B[ ] in XMM Registers SSE Assembly (N=1024) Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 8 / 24

  18. Vectorization of Stencils Vectorizing Stencil Computation for (t = 0; t < T; t++) for (i = 4; i < N; i++) A[i] += B[i-1] * B[i]; Solution1: load + shuffle Solution2: unaligned load Our Solution: StVEC (no shuffle, no unaligned load) B[ ] in XMM Registers SSE Assembly (N=1024) Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 8 / 24

  19. Enhancing Vector ISA with StVEC Enhancing Vector ISA with StVEC Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 9 / 24

  20. Enhancing Vector ISA with StVEC Execution Model Building Unaligned Vector Operands Idea: build an unaligned operand during register read Only one unaligned operand suffice for stencils Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 10 / 24

  21. Enhancing Vector ISA with StVEC Execution Model Building Unaligned Vector Operands Idea: build an unaligned operand during register read Only one unaligned operand suffice for stencils Build the unaligned operand (i.e. VOPR x ) with two source regs base and extension Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 10 / 24

  22. Enhancing Vector ISA with StVEC Execution Model Building Unaligned Vector Operands Idea: build an unaligned operand during register read Only one unaligned operand suffice for stencils Build the unaligned operand (i.e. VOPR x ) with two source regs base and extension 16x128-bit vector register file base = VR 1 , extension = VR 14 source offset VOPR x Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 10 / 24

  23. Enhancing Vector ISA with StVEC Execution Model Building Unaligned Vector Operands Idea: build an unaligned operand during register read Only one unaligned operand suffice for stencils Build the unaligned operand (i.e. VOPR x ) with two source regs base and extension 16x128-bit vector register file base = VR 1 , extension = VR 14 source offset VOPR x 0 X 1 , 0:4 ( aligned ) VR 1 Naser Sedaghati (CSE @ Ohio State) StVEC: A Vector Instruction Extension PACT’11 10 / 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend