# Adapting the GACT-X Aligner to Accelerate Minimap2 in an FPGA Cloud Instance
## 2 Materials and Methods
### GACT-X in Minimap2: Performance Assessment and Optimization
Figure 6: Illustration of GACT-X’s host-FPGA data transfer flowchart. The inputs correspond to many pairs of read and reference anchor-separated sub-sequences (as seen in Section 2.1), which were collected from Minimap2 after the seeding and chaining steps (left of the figure). The sequence of steps for the software–hardware interaction is as follows: (1) sequential transfer of each anchor-separated sub-sequence from the host server to the FPGA board into the “ref_seq” and “query_seq” buffers; (2) the execution of each anchor-separated sub-sequence with a looped data transfer between the host and the FPGA, corresponding to the number of tiles. For this looped execution (5 tiles): (a) the host sets the tile’s starting indexes with variables “ref_offset” and “query_offset”, and the tile’s size with variables “ref_len” and “query_len”, sending them to the FPGA; (b) the FPGA kernel calculates the alignment for the tile and writes the alignment score, the maximum score’s indexes with variables “ref_pos” and “query_pos”, and the number of trace-back pointers in the band back to the host, all from the “tile_output” buffer. The trace-back pointers are transferred from the “tb_output” buffer. transfer latency that undermines the gains obtained with a faster alignment performed in the kernel. The first optimization proposed for the GACT-X implementation was to reduce the number of transfers between the host and FPGA, mitigating the aforementioned latency issue. Instead of aligning each anchor-separated sub-sequence, the strategy was changed in this work to consider the alignment of the first-anchor-extended sub-sequences, i.e., the portion from the first anchor to the end of the read sequence and its corresponding reference sub-sequence. With this, the alignment was performed in a semi-global fashion. The new query and target lengths were almost the same as the reads' lengths. The remainder sub-sequence on the left side of the first anchor was processed in Minimap2's software, and its alignment result was clipped to GACT-X's alignment result. Regarding Figure 6, the input sub-sequences on the left, generated by the chaining step, are changed to longer ones. With this optimization, longer sub-sequences demand larger tiles; otherwise, the number of tile processing cycles, seen on the right side of Figure 6, will be large, corresponding to a high number of data transfers through the PCIe interface. In GACT-X's original Verilog files, used to build the binary code of the kernels, the tile size is set up to be at most 2048. In order to test the behavior of the software-hardware implementation, its performance was measured under different tile sizes, and a new AFI was generated with an increased limit. The same process of measuring times for the alignment of the first 100,000 simulated reads was performed. This time, the multiple ksw functions call for each read after the first anchor had its processing times added up, whereas GACT-X performed the alignment of the first-anchor-extended sequences. The total processing times for GACT-X were measured for 8 different tile sizes from 1000 to 8000. Figure 8 shows that GACT-X's performance improved as the tile sizes increased from 1000 to their peak at 4000. However, subsequently, the performance started to worsen. It is suspected that this is due to BRAM saturation since the direction pointer storage is linearly cumulative and increases with the tile size. A new optimization is established for the GACT-X's implementation with the tile size set to 4000, which has provided a speed-up of 1.68\(\times\) over Minimap2's ksw software. The speed-up increased with the input sub-sequence's lengths, reaching up to 1.91\(\times\). Figure 7: Ksw function and GACT-X average processing times per length for anchor-separated sub-sequences for the simulated dataset. The processed subsequences are classified by their length, in 100 base intervals, up to 1000 bases. The times are longer for GACT-X (dashed and dotted curve) compared to the ksw function execution (dotted curve).