Unified GPU Kernel Execution via Conditional Compilation Macros

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current GPU computation languages, such as CUDA and OpenCL, are platform-dependent, requiring separate code bases and significant development efforts to maintain compatibility across different hardware platforms, which leads to inefficiencies and limitations in application integration.

Innovation Solution

A method and apparatus that identify the GPU on a computing device and access macros representing differences between GPU computation languages, expanding these macros to execute kernels on the device, allowing a single kernel to run on multiple platforms by substituting tokens with language-specific source code.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If separate code bases are maintained for CUDA and OpenCL, then platform compatibility is achieved, but code complexity and maintenance difficulty increase significantly

Engineering Contradiction:
Improveplatform compatibilityVSAvoidcode complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The code base is segmented into platform-specific sections marked by macros (e.g., #ifdef CUDA, #ifdef OPENCL). Each platform-specific section contains only the code necessary for that particular platform, allowing the overall code to be divided into universal and platform-dependent parts. This segmentation enables a single code base to serve multiple platforms without requiring separate complete code bases for each platform.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Platform-specific code is extracted into separate macro blocks that can be conditionally included or excluded based on the target platform. By extracting CUDA-specific code into #ifdef CUDA blocks and OpenCL-specific code into #ifdef OPENCL blocks, the patent removes the need to maintain entire separate code bases, keeping only the necessary platform-specific portions within a unified code structure.

Inventive Principle:
Principle #2Taking out (Extraction)

2Adaptability or versatility

If a new unified language or compiler is developed, then support for multiple platforms is enabled, but development time and expense increase significantly

Engineering Contradiction:
Improvemulti-platform supportVSAvoiddevelopment time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent creates a universal code base that can function across multiple platforms (NVIDIA CUDA and non-NVIDIA OpenCL) by using conditional compilation macros. Instead of developing a completely new unified language, the existing CUDA and OpenCL languages are made universal through the use of #ifdef directives, allowing the same code to be compiled and executed on different platforms without requiring a new language specification or compiler infrastructure.

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

Solution Approach 2:

The patent introduces an intermediary layer of preprocessor macros (#ifdef, #ifndef, #endif) that mediates between the unified code base and platform-specific implementations. These macros act as a translation layer that directs the compiler to include or exclude specific code sections based on the target platform, enabling multi-platform support without requiring a new intermediary language or compiler.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Adaptability or versatility

If only OpenCL is supported, then platform independence is achieved, but existing CUDA code functionality is lost

Engineering Contradiction:
Improveplatform independenceVSAvoidcode functionality
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The patent makes the code base dynamic by using conditional compilation that adapts to the target platform at compile time. The #ifdef directives allow the code to dynamically include or exclude platform-specific sections based on whether it's being compiled for CUDA or OpenCL, ensuring that existing CUDA code functionality is preserved when targeting NVIDIA platforms while maintaining OpenCL compatibility for other platforms.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent applies local quality by making specific portions of the code platform-dependent through conditional compilation. Instead of making the entire code base uniform, the patent allows different sections of the code to have different qualities or implementations based on the platform - CUDA-specific optimizations and features are enabled only when compiling for NVIDIA hardware, while OpenCL-specific code is enabled for other platforms.

Inventive Principle:
Principle #3Local quality

4Productivity

If platform-specific code is used, then optimal performance for specific hardware is achieved, but portability to other platforms is reduced

Engineering Contradiction:
Improveexecution efficiencyVSAvoidportability
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The code is segmented into performance-optimized platform-specific sections using #ifdef macros. Each platform (CUDA/OpenCL) can have its own optimized implementation of specific functions or algorithms, allowing optimal execution efficiency for each hardware platform while maintaining portability through the unified code structure that conditionally includes the appropriate optimizations based on the target platform.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS9275426B2Method and apparatus for unifying graphics processing unit computation languages
Publication Date: 2016.03.01 ADOBE INC
  • US9275426B2 patent drawing
  • US9275426B2 patent drawing
  • US9275426B2 patent drawing

AI summary

A method and apparatus for unifying graphics processing unit (GPU) computation languages is disclosed. The method comprises identifying a GPU of a computer system; accessing a plurality of macros representing a difference in source code between a first GPU computation language and a second GPU computation language, expanding each macro in the plurality of macros based on the identified GPU and executing a kernel on the computer system using the expanded macro.