Loop pipelining semantics using structured control flow (SCF) operations with explicitly passed-in asynchronous tokens
A method includes a method includes receiving, by a compiler of a host of a computing system, input code, generating, by the compiler, pipelined input code by adding first tokens in a loop iteration argument field of a loop in the input code to pipeline the loop, the first tokens configured to sequentialize and serialize loop operations, a quantity of the first tokens based on a quantity of pipeline stages, and providing, by the host, the pipelined input code to a controller of an integrated circuit (IC) of the computing system.
1 . A method comprising:
receiving, by a compiler of a host of a computing system, input code;
generating, by the compiler, pipelined input code by adding first tokens in a loop iteration argument field of a loop in the input code to pipeline the loop, the first tokens configured to sequentialize and serialize loop operations, wherein a quantity of the first tokens is N+2, wherein N is based on a quantity of pipeline stages; and
providing, by the host, the pipelined input code to a controller of an integrated circuit (IC) of the computing system.
2 . The method of claim 1 , further comprising:
generating, by the compiler, asynchronous input code prior to generating the pipelined input code by adding second tokens to the loop iteration argument field, the second tokens configured to be passed sequentially through operations of the loop to provide asynchronous concurrency; and
generating the pipelined input code by replacing the second tokens with the first tokens in the loop iteration argument field.
3 . The method of claim 2 , wherein generating the asynchronous input code comprises inserting the second tokens in the loop iteration argument field based on loop-carried dependencies in the loop.
4 . The method of claim 1 , wherein generating the pipelined input code comprises modifying a body of the loop so that execution of each loop operation is dependent on receipt of at least one of the first tokens.
5 . The method of claim 1 , wherein generating the pipelined input code comprises unrolling the loop into N memory blocks, wherein N is an integer equal to the quantity of the pipeline stages.
6 . The method of claim 5 , wherein generating the pipelined input code further comprises generating a producer thread and a consumer thread for each of the pipeline stages.
7 . The method of claim 1 , further comprising:
generating, by the compiler, a control and dataflow graph (CDFG) representing the pipelined input code, the CDFG including dependency edges that connect loop operations to one another, and wherein providing, by the host, the pipelined input code to the controller of the IC of the computing system comprises the host providing the CDFG to the controller.
8 . A computer system comprising:
a memory comprising instructions; and
a processor coupled to the memory and configured to execute the instructions, the instructions when executed cause the processor to:
receive input code; and
generate pipelined input code by adding first tokens in a loop iteration argument field of a loop in the input code to pipeline the loop, the first tokens configured to sequentialize and serialize loop operations, wherein a quantity of the first tokens is N+2, and wherein N is based on a quantity of pipeline stages.
9 . The computer system of claim 8 , wherein the processor is further caused to:
generate asynchronous input code prior to generating the pipelined input code by adding second tokens to the loop iteration argument field, the second tokens configured to be passed sequentially through operations of the loop to provide asynchronous concurrency; and
generate the pipelined input code by replacing the second tokens with the first tokens in the loop iteration argument field.
10 . The computer system of claim 9 , wherein generating the asynchronous input code comprises inserting the second tokens in the loop iteration argument field based on loop-carried dependencies in the loop.
11 . The computer system of claim 8 , wherein generating the pipelined input code comprises modifying a body of the loop so that execution of each loop operation is dependent on receipt of at least one of the first tokens.
12 . The computer system of claim 8 , wherein generating the pipelined input code comprises unrolling the loop into N memory blocks, wherein N is an integer equal to the quantity of the pipeline stages.
13 . The computer of claim 12 , wherein generating the pipelined input code further comprises generating a producer thread and a consumer thread for each of the pipeline stages.
14 . An integrated circuit (IC) comprising:
a controller configured to receive pipelined input code from a host including a compiler to:
receive input code; and
generate the pipelined input code by adding first tokens in a loop iteration argument field of a loop in the input code to pipeline the loop, the first tokens configured to sequentialize and serialize loop operations, wherein a quantity of the first tokens is N+2, wherein N is based on a quantity of pipeline stages.
15 . The IC of claim 14 , wherein the compiler is to:
generate asynchronous input code prior to generating the pipelined input code by adding second tokens to the loop iteration argument field, the second tokens configured to be passed sequentially through operations of the loop to provide asynchronous concurrency; and
generate the pipelined input code by replacing the second tokens with the first tokens in the loop iteration argument field.
16 . The IC of claim 15 , wherein generating the asynchronous input code comprises inserting second tokens in the loop iteration argument field based on loop-carried dependencies in the loop.
17 . The IC of claim 14 , wherein generating the pipelined input code comprises modifying a body of the loop so that execution of each loop operation is dependent on receipt of at least one of the first tokens.
18 . The IC of claim 14 , wherein generating the pipelined input code comprises unrolling the loop into N memory blocks, wherein N is an integer equal to the quantity of the pipeline stages.