Emulating Pointers in GPU Code via Array Indexing

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

GPU programming models lack support for pointers, restricting memory access and leading to performance issues due to anti-patterns in code, as they do not fully abstract memory operations and require explicit memory type annotations.

Innovation Solution

The method involves emulating pointers by defining arrays to store local and shared variables, using tag and offset variables to represent pointers, and replacing pointer operations with array-based instructions to maintain functionality across different memory types, allowing for direct access and dereferencing within a single function.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If GPU programming models lack pointer support or restrict pointer usage, then memory access control and performance optimization are improved, but code functionality and developer ease of use deteriorate

Engineering Contradiction:
Improvememory access controlVSAvoidcode functionality
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent introduces an intermediary translation layer that converts C++ pointer operations into GPU-compatible array indexing operations. This mediator preserves the high-level pointer semantics while translating them into low-level array access patterns that GPUs can execute efficiently, resolving the contradiction between maintaining pointer functionality and ensuring GPU performance optimization

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The invention changes the fundamental parameters of memory access by transforming pointer-based indirect addressing into array-based direct indexing. This parameter transformation allows the code to maintain functional equivalence while adapting to GPU memory model constraints, enabling both ease of use and performance optimization

Inventive Principle:
Principle #35Parameter changes

2Adaptability or versatility

If pointer operations are emulated using arrays and tag-offset variables, then compatibility with GPU memory models is improved, but code complexity increases

Engineering Contradiction:
ImproveGPU memory model compatibilityVSAvoidcode complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent segments the pointer emulation into distinct components: tag variables for memory space identification and offset variables for position within that space. This segmentation allows complex pointer semantics to be broken down into simpler, manageable operations that are easier to implement and optimize on GPUs

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The tag-offset variable system provides universal functionality across different memory types (global memory, local memory, shared memory). A single unified approach handles multiple memory access patterns, reducing the need for separate specialized code paths and actually simplifying the overall implementation despite the increased abstraction

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

3Adaptability or versatility

If multi-stage compilation is used to translate between higher level languages, then adaptability to different platforms is improved, but translation accuracy and functionality preservation deteriorate

Engineering Contradiction:
Improveplatform adaptabilityVSAvoidfunctionality preservation
Core Design Contradiction:
Adaptability or versatilityVSManufacturing precision

Solution Approach 1:

The patent performs preliminary translation of C++ code into an intermediate representation that explicitly models memory access patterns before final GPU code generation. This preliminary action captures pointer semantics early in the compilation process, ensuring functionality is preserved through subsequent translation stages while maintaining platform adaptability

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS8997066B2Emulating pointers
Publication Date: 2015.03.31 MICROSOFT TECHNOLOGY LICENSING LLC
  • US8997066B2 patent drawing
  • US8997066B2 patent drawing
  • US8997066B2 patent drawing

AI summary

The present invention extends to methods, systems, and computer program products for emulating pointers. Pointers can be emulated by replacing the pointers with a <variable#, offset> pair and replacing each dereference site with a switch on the tag and a switch body that executes the emulated pointer access on the corresponding variable the pointer points to. Data flow optimizations can be used to reduce the number of switches and/or reduce the number of cases which need be considered at each emulated pointer access sites.