# Fast Overlap Detection between Hard-Core Colloidal Cuboids and Spheres. The OCSI Algorithm
## 2 Algorithms
Larger spheres, with \(R^{*}=5\) (frames \(c\) in Figures 2 and 3), induce a different performance resulting in an opposite concavity of the run-time surface as compared to that observed for smaller spheres. In this case, for the results obtained using Intel(r) Compilers and specifying AVX instruction set during compilation, the slowest detection is measured at \((L^{*},W^{*})=(7,8)\) and \((3,5)\) for QRI and QRF in C/C++ program, respectively, and \((6,7)\) and \((3,5)\) for QRI and QRF in F90 program, respectively. For the parameters set in these benchmarks, in terms of acceptance ratio and shapes of cuboids and spheres, QRF is generally faster than QRI. The only exceptions to this tendency are observed for the C/C++ program compiled either with Intel(r) C Compilers with AVX instructions (panel (a) of Figure 2) or with GNU C++ Compiler with SSE instructions (see Supplementary Information), in both cases when the spheres are especially small (\(R^{*}=0.05\)). The difference in performance between QRI and QRF might also be due to how data are stored and read by C/C++ and F90 compilers. As a matter of fact, [PERSON] and coworkers had already noticed that the run-times of QRI and QRF were very similar for acceptance ratios of approximately 50%, although their collision-detection method tests run-times for sets of configurations with cuboids and sphere of random dimensions [7]. Despite the main differences between C /C++ and Fortran programming languages, the average run-time performance of QRI and QRF with respect to the radius of the sphere available in C is similar to the ones we translated and provide also in Fortran in our benchmark source code. To more easily compare the efficiency of the algorithms tested, the run-times computed for each possible combination of cuboid and sphere size studied here have been averaged out for each value of \(R^{*}\). The resulting averaged run-times for all these cases, which are 400 considering all the possible combinations of \(1\leq L^{*}\leq 20\) and \(1\leq W^{*}\leq 20\) of the cuboids, are reported in Tables 1 and 2. For every averaged run-time reported in both tables, we evaluated also its standard deviation, which resulted to be less than 0.5 ms for all the cases. For comparison with benchmarks performed by [PERSON] et al., the run-times are reported with a precision of 1 ms [7]. We stress that these average run-times should be taken as indicative values for QRI and QRF as their speed strongly depends on the cuboid geometry. We observe that QRI and QRF average run-times tend to be longer for larger spheres, with no significant difference between C/C++ and F90. In contrast, both SSE-intr and OCSI are completely insensible to the sphere radius as no relevant change in their average run-time is detected between \(R^{*}=0.05\) and 0.5. Regarding the performance of OCSI, we notice that its C version is faster than the F90 version for both the compilers. Moreover, checking the optimization report of the two compilers, we observed that GNU compilers were not capable of vectorizing the first loop of OCSI over the dot products. This seems to be the reason why Intel(r) Compilers performed better in terms of run-time efficiency. Anyway, except the F90 version compiled with GNU Fortran Compiler, for all the other cases the average OCSI run-time to analyse \(2\times 10^{6}\) cuboid-sphere configurations oscillates between 10 and 12 ms. Even for the worst-case scenario, OCSI is still faster than QRI and QRF. We also notice that the performance of OCSI compiled using SSE and AVX instruction sets is very similar to that of SSE-intr, with our algorithm approximately 1 ms faster or slower than SSE-intr, depending on the compiler and the instruction sets called during compilation. This difference, per se, would not be especially significant if the overlap checks were limited to \(2\times 10^{6}\) configurations. However, the typical number of configurations generated in Monte Carlo simulations of colloids is usually a few millions per particle, which are rarely less than a few thousands.