#include "record_pmem_direct.h" #include #include #include #include #include #include #include "timer.h" #include #include "config.h" #include "ips4o/include/ips4o.hpp" using namespace std; struct Config conf; int main(int argc, char **argv) { Timer timer; string input_file = argv[1]; int fd = open(input_file.c_str(), O_RDWR | O_DIRECT); if (fd < 0) { printf("Couldn't open input file %s: %s\n", input_file.c_str(), strerror(errno)); exit(1); } struct stat st; stat(input_file.c_str(), &st); record_t *mapped_buffer = (record_t *)mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_POPULATE, fd, 0); if (mapped_buffer == MAP_FAILED) { printf("Failed to mmap read file of size %lu: %s\n", st.st_size, strerror(errno)); return -1; } conf.sort_thrds = 20; timer.start("SORT"); ips4o::parallel::sort(mapped_buffer, mapped_buffer + st.st_size / 100, std::less<>{}); timer.end("SORT"); printf("Sort time: %f\n", timer.get_overall_time("SORT")); }