# Fast Overlap Detection between Hard-Core Colloidal Cuboids and Spheres. The OCSI Algorithm
## 2 Algorithms
## 4 Results and Discussion

Due to the large number of benchmarks performed, we intended to report here the behaviour of the run-time efficiency of the algorithms with respect to the shape of the cuboid and the sphere only for the programs compiled using Intel(r) C and Intel(r) Fortran Compiler, enabling the use of AVX instruction set for SIMD parallelization. The dependence of the algorithms run-time with respect to the shape of the cuboid and the sphere is generally similar for all the compilers and the instruction sets specified during compilation. All the results obtained for the other cases are reported in the Supplementary Information. The relative performance of each algorithm is assessed in Figures 2 and 3 for codes written in C and F90, respectively. Figure 2 offers a benchmark between QRI, QRF, SSE-intr and OCSI, while Figure 3 only for QRI, QRF and OCSI, since SSE-intr uses specific Intel(r) intrinsic functions: these sets of functions enable to use SIMD instructions (like SSE and AVX) without the need of an assembly code for vectorization, but they are available only for C programming language. Both figures report the run-times for detecting collisions between one cuboid of \(1\leq L^{*}\leq 20\) and \(1\leq W^{*}\leq 20\) and one sphere of radius \(R^{*}=0.05\) (frames \(a\)), \(0.5\) (frames \(b\)) and \(5\) (frames \(c\)). The \(N_{c}\) random configurations tested per run have been produced at the constant acceptance ratio of 40%, which is within the usual range of values employed in Metropolis Monte Carlo simulations of hard-core particles [52]. It is evident that SSE-intr and OCSI perform significantly better than QRI and QRF under the conditions specified here, although we have also tested cuboids of larger length and width (up to \(100T\)) with the same acceptance ratio and observed very similar tendencies. The difference in performance is especially evident at \(R^{*}=5\) as SSE-intr and OCSI run-times are up to 5 and 6 times faster than QRF and QRI, respectively. In general, C codes show a better performance than F90 codes, although this difference is not substantial. Interestingly enough, SSE-intr and OCSI do not present any relevant dependence on the cuboid and sphere geometry, being the run-times basically constant across the whole range of dimensions. This is probably due to the SIMD parallelism implemented, different from QRI and QRF, which have to run in serial for their use of quick rejection tests (see lines 6 and 9 in QRI and line 5 in

Figure 3: Run-times of algorithms written in F90 that detect collision between one cuboid of length \(L^{*}\) and width \(W^{*}\) and one sphere of radius \(R^{*}=0.05\) (**a**), \(0.5\) (**b**) and \(5\) (**c**). The program was compiled using Intel® Fortran Compiler and enabled the generation of AVX instructions. Each test generates \(2\times 10^{6}\) random configurations at constant acceptance ratio of 40%. Figure 2: Run-times of algorithms written in C/C++ that detect collision between one cuboid of length \(L^{*}\) and width \(W^{*}\) and one sphere of radius \(R^{*}=0.05\) (**a**), \(0.5\) (**b**) and \(5\) (**c**). The program was compiled using Intel® C Compiler and enabled the generation of Advanced Vector Extensions (AVX) instructions. Each test generates \(2\times 10^{6}\) random configurations at constant acceptance ratio of 40%. QRF). Basically, if the quick rejection test is true for the first dot product, the algorithms exit the loop with negative result (\(\mathcal{C}\) and \(\mathcal{S}\) do not overlap) with no need to compute the remaining two. The geometry of both cuboid and sphere exhibits a very intriguing effect on the performance of QRI and QRF as the shape of the run-time surfaces in the \(L^{*}W^{*}\) plane suggests. More specifically, for spheres with \(R^{*}=0.5\) (frames \(b\) in Figures 2 and 3) the time required for the collision detection decreases upon increasing the cuboid dimensions, with the shortest time detected at \(L^{*}=W^{*}=20\) (disk-like cuboid).