Smart GEMM Kernels for GPU Matrix Multiplication

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current GPU implementations of general matrix-matrix multiplication (GEMM) operations, such as those in the MAGMA library, suffer from inefficiencies when dealing with non-square matrices, particularly tall-and-skinny matrices, due to fixed kernel parameters that do not optimize performance for all matrix sizes, leading to sub-optimal parallelization and increased storage padding requirements.

Innovation Solution

The development of a system that generates a set of GPU kernels with complementary strengths, including variable-K and constant-K GEMM kernels, along with a Smart GEMM testing technique, to select the best kernel for specific matrix dimensions, eliminating the need for storage padding and optimizing performance across various matrix sizes.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If fixed kernel parameters are used for GEMM operations, then implementation simplicity is maintained, but performance optimization for various matrix sizes is lost

Engineering Contradiction:
ImproveGEMM operation speedVSAvoidkernel parameter variety
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent implements dynamic kernel parameter selection by creating multiple GEMM kernels with different block size configurations (e.g., 16x16, 32x32, 64x64) and selectively activating the appropriate kernel based on the input matrix dimensions. This allows the system to adapt to various matrix sizes while maintaining optimized performance, resolving the contradiction between simplicity and performance optimization.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes key parameters such as block sizes, thread block dimensions, and storage padding requirements based on the specific matrix dimensions being processed. By adjusting these parameters dynamically, the system achieves optimal performance for different matrix sizes without requiring a completely different kernel for each case, thus balancing simplicity and optimization.

Inventive Principle:
Principle #35Parameter changes

2Productivity

If storage padding is applied to optimize kernel performance, then computational efficiency is improved, but memory usage increases

Engineering Contradiction:
Improvecomputational efficiencyVSAvoidmemory usage
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The patent dynamically adjusts storage padding parameters based on the specific matrix dimensions and the selected kernel configuration. Instead of applying fixed padding to all operations, the system optimizes padding requirements for each case, reducing unnecessary memory allocation while maintaining computational efficiency. This resolves the contradiction by making padding adaptive rather than static.

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The patent applies storage padding selectively and partially - only when and where it is truly needed for optimal kernel performance. By avoiding excessive padding in cases where it is not necessary, the system maintains computational efficiency without unnecessarily increasing memory usage, thus resolving the contradiction between efficiency and memory consumption.

Inventive Principle:
Principle #16Partial or excessive action

3Productivity

If a single GEMM kernel is used for all matrix sizes, then device complexity is minimized, but performance is sub-optimal for specific matrix types

Engineering Contradiction:
Improveperformance for tall-and-skinny matricesVSAvoidnumber of kernels
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent segments the GEMM operation into multiple specialized kernels, each optimized for specific matrix size categories (e.g., tall-and-skinnymatrices, wide-and-short matrices, square matrices). By dividing the problem into segments with dedicated optimizations, the system achieves high performance for specific matrix types while keeping each individual kernel relatively simple, thus resolving the contradiction between performance and complexity.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent creates a universal kernel selection mechanism that chooses from multiple GEMM kernels based on input matrix dimensions. This multi-functional approach allows a single selection system to handle various matrix types optimally, achieving high performance across different matrix sizes without requiring manual intervention, thus balancing the number of kernels with ease of use.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS10073815B2System and method for speeding up general matrix-matrix multiplication on the GPU
Publication Date: 2018.09.11 GENESEE VALLEY INNOVATIONS LLC
  • US10073815B2 patent drawing
  • US10073815B2 patent drawing
  • US10073815B2 patent drawing

AI summary

A method and system for performing general matrix-matrix multiplication (GEMM) operations on a graphics processor unit (GPU) using Smart kernels. During operation, the system may generate a set of kernels that includes at least one of a variable-dimension variable-K GEMM kernel, a variable-dimension constant-K GEMM kernel, or a combination thereof. A constant-K GEMM kernel performs computations for matrices with a specific value of K (e.g., the number of columns in a first matrix and the number of rows in a second matrix). Variable-dimension GEMM kernels allow for flexibility in the number of rows and columns used by a thread block to perform matrix multiplication for a sub-matrix. The system may generate rules to select the best (e.g., fastest) kernel for performing computations according to the particular parameter combination of the matrices being multiplied.