IP Library Granted Patent US 11,947,941
Granted Patent B2
US 11,947,941 · App. 17/410,032 · Granted Apr 2, 2024

Dynamic computation offloading to graphics processing unit

Inventors: Nicola Ferraro (Rome, IT); Paolo Antinori (Novara, IT)
Assignee: Red Hat, Inc.
G06F8/451G06F8/4441G06F8/457
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,947,941
App. No.
17/410,032
Granted
Apr 2, 2024
Kind
B2
Abstract

A method includes receiving source code of a program to be compiled and compiling the source code of the program. Compiling the source code includes identifying a first function in the source code of the program that is a candidate to be executed by a graphics processing unit (GPU), generating a first intermediate representation and a second intermediate representation for the first function, and inserting a second function in the program in place of the first function, wherein the second function is to select one of the first intermediate representation or the second intermediate representation to be executed. The method further includes providing a compiled program package including the second function, the first intermediate representation and the second intermediate representation.

Claims (45)

1. A method comprising:

receiving source code of a program to be compiled;

compiling the source code of the program, wherein compiling the source code comprises: identifying, by a processing device, a first function in the source code of the program that is a candidate to be executed by a graphics processing unit (GPU);

generating, by the processing device, a first intermediate representation and a second intermediate representation for the first function; and

inserting, by the processing device, a second function in the program in place of the first function, wherein the second function comprises an interceptor function to invoke an optimizer function, the optimizer function to select between the first intermediate representation or the second intermediate representation to be executed at runtime in view of available computing resources and a state of one or more computing devices available to execute the first or second intermediate representations, and wherein the interceptor function returns a result of the selected first intermediate representation or the second intermediate representation in place of the first function; and

providing a compiled program package comprising the second function, the first intermediate representation and the second intermediate representation.

2. The method of claim 1 , wherein the optimizer function selects the first intermediate representation or the second intermediate representation in view of one or more metrics.

3. The method of claim 1 , wherein the first intermediate representation comprises an intermediate GPU kernel to be executed by the GPU and the second intermediate representation comprises an intermediate central processing unit (CPU) code to be executed by a CPU.

4. The method of claim 1 , wherein identifying the first function in the source code as a candidate to be executed by the GPU comprises:

determining that the first function is a self-contained function; and

determining that the first function is applied on a sequence of data.

5. The method of claim 1 , wherein identifying the first function in the source code as a candidate to be executed by the GPU comprises:

determining that the first function is associated with a flag indicating that the first function is to be executed by the GPU.

6. The method of claim 1 , wherein the first intermediate representation is compiled according to a first language and the second intermediate representation is compiled according to a second language.

7. A system comprising:

a memory; and

a processing device operatively coupled to the memory, the processing device to:

receive source code of a program to be compiled;

compile the source code of the program, wherein to compile the source code the processing device is to:

identify a first function in the source code of the program that is a candidate to be executed by a graphics processing unit (GPU);

generate a first intermediate representation and a second intermediate representation for the first function; and

insert a second function in the program in place of the first function, wherein the second function comprises an interceptor function to invoke an optimizer function, the optimizer function to select between the first intermediate representation or the second intermediate representation to be executed at runtime in view of available computing resources and a state of one or more computing devices available to execute the first or second intermediate representations, and wherein the interceptor function returns a result of the selected first intermediate representation or the second intermediate representation in place of the first function; and

provide a compiled program package comprising the second function, the first intermediate representation and the second intermediate representation.

8. The system of claim 7 , wherein the optimizer function selects the first intermediate representation or the second intermediate representation in view of one or more metrics.

9. The system of claim 7 , wherein the first intermediate representation comprises an intermediate GPU kernel to be executed by the GPU and the second intermediate representation comprises an intermediate central processing unit (CPU) code to be executed by a CPU.

10. The system of claim 7 , wherein to identify the first function in the source code as a candidate to be executed by the GPU, the processing device is to:

determine that the first function is a self-contained function; and

determine that the first function is applied on a sequence of data.

11. The system of claim 7 , wherein to identify the first function in the source code as a candidate to be executed by the GPU, the processing device is to:

determine that the first function is associated with a flag indicating that the first function is to be executed by the GPU.

12. The system of claim 7 , wherein the first intermediate representation is compiled according to a first language and the second intermediate representation is compiled according to a second language.

13. A non-transitory computer-readable storage medium including instructions that, when executed by a processing device, cause the processing device to:

receive source code of a program to be compiled;

compile the source code of the program, wherein to compile the source code the processing device is to:

identify, by the processing device, a first function in the source code of the program that is a candidate to be executed by a graphics processing unit (GPU);

generate, by the processing device, a first intermediate representation and a second intermediate representation for the first function; and

insert, by the processing device, a second function in the program in place of the first function, wherein the second function comprises an interceptor function to invoke an optimizer function, the optimizer function to select between the first intermediate representation or the second intermediate representation to be executed at runtime in view of available computing resources and a state of one or more computing devices available to execute the first or second intermediate representations, and wherein the interceptor function returns a result of the selected first intermediate representation or the second intermediate representation in place of the first function; and

provide a compiled program package comprising the second function, the first intermediate representation and the second intermediate representation.

14. The non-transitory computer-readable storage medium of claim 13 , wherein the optimizer function selects the first intermediate representation or the second intermediate representation in view of one or more metrics.

15. The non-transitory computer-readable storage medium of claim 13 , wherein the first intermediate representation comprises an intermediate GPU kernel to be executed by the GPU and the second intermediate representation comprises an intermediate central processing unit (CPU) code to be executed by a CPU.

16. The non-transitory computer-readable storage medium of claim 13 , wherein to identify the first function in the source code as a candidate to be executed by the GPU, the processing device is to:

determine that the first function is a self-contained function; and

determine that the first function is applied on a sequence of data.

17. The non-transitory computer-readable storage medium of claim 13 , wherein to identify the first function in the source code as a candidate to be executed by the GPU, the processing device is to:

determine that the first function is associated with a flag indicating that the first function is to be executed by the GPU.

Assignments (2)
CHANGE OF NAME Recorded Mar 3, 2026
From: RED HAT, INC.
To: RED HAT, LLC
Reel/Frame 074913/0759 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 24, 2021
From: FERRARO, NICOLA; ANTINORI, PAOLO
To: RED HAT, INC.
Reel/Frame 057268/0277 →