I am sorting 128-bit records in a large file (10s of GB). Algorithm works fine and currently using uint64_t
with two of these equal to one record. This is on a modern 64-bit system.
In the interest of code readability, am wondering if create a struct like typedef struct u128t {uint64_t hi, uint64_t} u128t
can be used in place of the two 64-bit records. This would make array indexing and assignment cleaner but I would have to implement a comparator function.
Is this a portable solution and should I expect this to run at the same speed as the original implementation?
Further reading:
- http://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html - for 128-bit systems
- http://en.wikipedia.org/wiki/C_data_types - c types
- Copy struct to struct in C - copy structs