简体   繁体   English

在内存中对大型向量进行排序的有效方法

[英]Efficient way to sort large vectors in-memory

I need to sort large vectors of user defined data-type of 32 GB size in memory on 64GB RAM High Performance Computing (HPC) machine again and again according to some user defined function. 我需要根据一些用户定义的功能,一次又一次地对64GB RAM高性能计算(HPC)机器上的32GB用户定义数据类型的大型向量进行排序。 I am using std::sort for the same. 我使用std :: sort相同。 However, it is turning out that std::sort is taking a large amount of time >1 hour. 但是,事实证明std :: sort花费了大量的时间> 1小时。 Is there some other function which I may use which sorts faster than std::sort. 我还可以使用其他一些比std :: sort排序更快的函数。

I am using the following gcc version on my system: gcc (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4 我在系统上使用以下gcc版本:gcc(Ubuntu / Linaro 4.6.4-6ubuntu2)4.6.4

You may want to use some mix of std::sort() (which uses quicksort algorithm) and mergesort and apply multithreading here. 您可能需要混合使用std :: sort()(使用quicksort算法)和mergesort并在此处应用多线程。

For example, having some amount of cores in CPU, it might be reasoble to split the data, sort each part by std::sort on the cores simultaneously, and then merge them just as a mergesort merges sorted arrays. 例如,在CPU中有一定数量的内核,可能需要拆分数据,同时在内核上按std :: sort对每个部分进行排序,然后将它们合并,就像mergesort合并已排序的数组一样。

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM