Some more constructors

This commit is contained in:
Eric Fischer
2017-11-10 13:59:57 -08:00
parent 069807caf4
commit 2d87059a04
2 changed files with 26 additions and 13 deletions
+10 -4
View File
@@ -425,6 +425,10 @@ struct queue_run_arg {
size_t start; size_t start;
size_t end; size_t end;
size_t segment; size_t segment;
queue_run_arg(size_t start1, size_t end1, size_t segment1)
: start(start1), end(end1), segment(segment1) {
}
}; };
void *run_parse_feature(void *v) { void *run_parse_feature(void *v) {
@@ -444,7 +448,6 @@ void runQueue() {
} }
std::vector<struct queue_run_arg> qra; std::vector<struct queue_run_arg> qra;
qra.resize(CPUS);
std::vector<pthread_t> pthreads; std::vector<pthread_t> pthreads;
pthreads.resize(CPUS); pthreads.resize(CPUS);
@@ -452,10 +455,13 @@ void runQueue() {
for (size_t i = 0; i < CPUS; i++) { for (size_t i = 0; i < CPUS; i++) {
*((*(feature_queue[0].sst))[i].layer_seq) = *((*(feature_queue[0].sst))[0].layer_seq) + feature_queue.size() * i / CPUS; *((*(feature_queue[0].sst))[i].layer_seq) = *((*(feature_queue[0].sst))[0].layer_seq) + feature_queue.size() * i / CPUS;
qra[i].start = feature_queue.size() * i / CPUS; qra.push_back(queue_run_arg(
qra[i].end = feature_queue.size() * (i + 1) / CPUS; feature_queue.size() * i / CPUS,
qra[i].segment = i; feature_queue.size() * (i + 1) / CPUS,
i));
}
for (size_t i = 0; i < CPUS; i++) {
if (pthread_create(&pthreads[i], NULL, run_parse_feature, &qra[i]) != 0) { if (pthread_create(&pthreads[i], NULL, run_parse_feature, &qra[i]) != 0) {
perror("pthread_create"); perror("pthread_create");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
+16 -9
View File
@@ -302,6 +302,10 @@ struct sort_arg {
size_t nmerges; size_t nmerges;
long long unit; long long unit;
int bytes; int bytes;
sort_arg(int task1, int cpus1, long long indexpos1, struct mergelist *merges1, int indexfd1, size_t nmerges1, long long unit1, int bytes1)
: task(task1), cpus(cpus1), indexpos(indexpos1), merges(merges1), indexfd(indexfd1), nmerges(nmerges1), unit(unit1), bytes(bytes1) {
}
}; };
void *run_sort(void *v) { void *run_sort(void *v) {
@@ -726,18 +730,21 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split
} }
pthread_t pthreads[CPUS]; pthread_t pthreads[CPUS];
struct sort_arg args[CPUS]; std::vector<sort_arg> args;
for (size_t a = 0; a < CPUS; a++) { for (size_t a = 0; a < CPUS; a++) {
args[a].task = a; args.push_back(sort_arg(
args[a].cpus = CPUS; a,
args[a].indexpos = indexpos; CPUS,
args[a].merges = merges; indexpos,
args[a].indexfd = indexfds[i]; merges,
args[a].nmerges = nmerges; indexfds[i],
args[a].unit = unit; nmerges,
args[a].bytes = bytes; unit,
bytes));
}
for (size_t a = 0; a < CPUS; a++) {
if (pthread_create(&pthreads[a], NULL, run_sort, &args[a]) != 0) { if (pthread_create(&pthreads[a], NULL, run_sort, &args[a]) != 0) {
perror("pthread_create"); perror("pthread_create");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);