Systems and methods for compiler-based full-function vectorization
AssigneeApple Inc.
InventorJeffry E. Gonion
Life of this patent
Estimating the term…
Abstract
Systems and methods for the vectorization of software applications are described. In some embodiments, a compiler may automatically generate both scalar and vector versions of a function from a single source code description. A vector interface may be exposed in a persistent dependency database that is associated with the function. This may allow a compiler to make vector function calls from within vectorized loops, rather than making multiple serialized scalar function calls from within a vectorized loop. This may in turn facilitate the vectorization of hierarchical code, which may improve application performance when vector execution resources are available.
Claims21
A system comprising:
- one or more memories that, during operation, store instructions;
- and
- one or more processors that, during operation, retrieve instructions from the one or more memories and execute the instructions to cause the system to perform operations comprising:
- compiling a scalar version of a called function from a single source code description of the called function;
- compiling a vector version of the called function from the single source code description of the called function;
- generating a persistent dependency database associated with the called function, wherein the persistent dependency database stores an indication of a vector interface associated with the vector version of the called function, and wherein the indication is stored in the persistent dependency database prior to beginning compilation of source code including a calling function that calls the called function;
- identifying a call to the scalar version of the called function within the source code that includes the calling function, the identifying occurring subsequent to beginning compilation of the source code including the calling function;
- in response to identifying the call, accessing the persistent dependency database;
- and
- compiling the calling function to utilize the vector version instead of the scalar version of the called function in response to the detecting the indication of the vector interface stored in the persistent dependency database.
A non-transitory computer-readable storage medium having program instructions stored therein that, in response to execution by a computer system, cause the computer system to perform operations comprising:
- identifying a calling function during a process of compiling source code including the calling function, the calling function including a call to a called function using a scalar interface;
- accessing a persistent dependency database to retrieve information associated with the called function, wherein the persistent dependency database persistently stores the information such that the information is accessible across distinct compiler invocations for different functions, and wherein the information retrieved from the persistent dependency database is already stored within the persistent dependency database prior to beginning compilation of the source code including the calling function;
- and
- compiling the calling function to utilize a vector interface of the called function instead of a scalar interface of the called function in response to the persistent dependency database indicating that the called function exposes the vector interface.
A non-transitory computer-readable storage medium having program instructions stored therein that, in response to execution by a computer system, cause the computer system to perform operations including:
- receiving a called function to be compiled;
- generating a vector interface for the called function;
- and
- storing an indication of the vector interface in a persistent dependency database associated with the function, wherein the persistent dependency database persistently stores information that is accessible across distinct compiler invocations for different functions, and wherein said storing occurs prior to beginning compilation of source code that includes a calling function that calls the called function.
A method, comprising:
- performing, by one or more computers:
- identifying a calling function during a process of compiling source code including the calling function, the calling function including a loop that includes a call to a called function;
- accessing a persistent dependency database to retrieve information associated with the called function, wherein the persistent dependency database persistently stores the information such that the information is accessible across distinct compiler invocations for different functions, and wherein the information retrieved from the persistent dependency database is already stored within the persistent dependency database prior to beginning compilation of the source code including the calling function;
- and
- vectorizing the loop of the calling function, wherein vectorizing includes:
- in response to determining from the persistent dependency database that the called function exposes a vector interface, compiling the calling function to utilize the vector interface, such that within the vectorized loop, one or more calls are made to the called function via the vector interface.
A method, comprising:
- performing, by one or more computers:
- receiving a called function to be compiled;
- generating a scalar version of the called function from a single source code description of the function, the scalar version having a scalar interface;
- generating a vector version of the called function from the single source code description of the function, the vector version having a vector interface;
- storing respective indications of the scalar interface and the vector interface in a persistent dependency database associated with the called function, wherein the respective indications are stored in the persistent dependency database prior to beginning compilation of source code including a calling function that calls the called function.
Dependencies are inferred from the claim text.