Vectorizing merge/union of two sorted arrays

半城伤御伤魂 提交于 2020-01-15 08:43:45

问题


I have recently started looking into opportunities to speed up my code by using vector instructions. My code heavily relies on operations with sets - for simplicity let us assume that these are represented as sorted arrays of 16bit unsigned integers. The operations I need to perform are:

  1. Intersection (i.e., each element contained in both sets is to be present in the output set)
  2. Union (i.e., each element that is contained in at least one of the sets is to be present in the output set exactly once)
  3. Merge (works exactly as merge in merge-sort, the output is a sorted "concatenation" of both arrays)

I have found works focusing on vectorizing intersection (e.g., http://www.adms-conf.org/p1-SCHLEGEL.pdf) but I had little luck with finding anything for the other two operations. I am curious, is it possible to speed up also the other two operations by vectorization? (I am targeting CPUs either with AVX or AVX2 instruction sets.)

来源:https://stackoverflow.com/questions/49336261/vectorizing-merge-union-of-two-sorted-arrays

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!