From 4854c57e2277c4e6be642cdec9bf307769f0f435 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Tue, 23 Jan 2024 10:21:45 -0800 Subject: [PATCH] "tas" (type_and_string) => "sv" (serial_val) --- main.cpp | 8 ++++---- tile-join.cpp | 42 +++++++++++++++++++------------------- tile.cpp | 56 +++++++++++++++++++++++++-------------------------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/main.cpp b/main.cpp index d4738acd..185c1c64 100644 --- a/main.cpp +++ b/main.cpp @@ -395,7 +395,7 @@ static void merge(struct mergelist *merges, size_t nmerges, unsigned char *map, } struct sort_arg { - int task; + int svk; int cpus; long long indexpos; struct mergelist *merges; @@ -404,8 +404,8 @@ struct sort_arg { long long unit; 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) { + sort_arg(int svk1, int cpus1, long long indexpos1, struct mergelist *merges1, int indexfd1, size_t nmerges1, long long unit1, int bytes1) + : svk(svk1), cpus(cpus1), indexpos(indexpos1), merges(merges1), indexfd(indexfd1), nmerges(nmerges1), unit(unit1), bytes(bytes1) { } }; @@ -413,7 +413,7 @@ void *run_sort(void *v) { struct sort_arg *a = (struct sort_arg *) v; long long start; - for (start = a->task * a->unit; start < a->indexpos; start += a->unit * a->cpus) { + for (start = a->svk * a->unit; start < a->indexpos; start += a->unit * a->cpus) { long long end = start + a->unit; if (end > a->indexpos) { end = a->indexpos; diff --git a/tile-join.cpp b/tile-join.cpp index 7354a960..99a115b6 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -206,11 +206,11 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map>(key, std::pair(val, tas))); + attributes.insert(std::pair>(key, std::pair(val, sv))); key_order.push_back(key); } @@ -253,14 +253,14 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map>(joinkey, std::pair(outval, tas))); + attributes.insert(std::pair>(joinkey, std::pair(outval, sv))); key_order.push_back(joinkey); } } @@ -821,7 +821,7 @@ void *join_worker(void *v) { return NULL; } -void dispatch_tasks(std::map> &tasks, std::vector> &layermaps, sqlite3 *outdb, const char *outdir, std::vector &header, std::map> &mapping, std::set &exclude, std::set &include, int ifmatched, std::set &keep_layers, std::set &remove_layers, json_object *filter, struct tileset_reader *readers) { +void dispatch_svks(std::map> &svks, std::vector> &layermaps, sqlite3 *outdb, const char *outdir, std::vector &header, std::map> &mapping, std::set &exclude, std::set &include, int ifmatched, std::set &keep_layers, std::set &remove_layers, json_object *filter, struct tileset_reader *readers) { pthread_t pthreads[CPUS]; std::vector args; @@ -841,14 +841,14 @@ void dispatch_tasks(std::map> &tasks, std::vector< } size_t count = 0; - // This isn't careful about distributing tasks evenly across CPUs, + // This isn't careful about distributing svks evenly across CPUs, // but, from testing, it actually takes a little longer to do // the proper allocation than is saved by perfectly balanced threads. - for (auto ai = tasks.begin(); ai != tasks.end(); ++ai) { + for (auto ai = svks.begin(); ai != svks.end(); ++ai) { args[count].inputs.insert(*ai); count = (count + 1) % CPUS; - if (ai == tasks.begin()) { + if (ai == svks.begin()) { if (!quiet) { fprintf(stderr, "%lld/%lld/%lld \r", ai->first.z, ai->first.x, ai->first.y); fflush(stderr); @@ -975,7 +975,7 @@ void decode(struct tileset_reader *readers, std::map()); } - std::map> tasks; + std::map> svks; double minlat = INT_MAX; double minlon = INT_MAX; double maxlat = INT_MIN; @@ -1014,14 +1014,14 @@ void decode(struct tileset_reader *readers, std::map= minzoom && current.first.z <= maxzoom) { zxy tile = current.first; - if (tasks.count(tile) == 0) { - tasks.insert(std::pair>(tile, std::vector())); + if (svks.count(tile) == 0) { + svks.insert(std::pair>(tile, std::vector())); } - auto f = tasks.find(tile); + auto f = svks.find(tile); f->second.push_back(current.second); } - // Advance the tileset_reader that we just added as a task. + // Advance the tileset_reader that we just added as a svk. // The reason this prefetches is so the tileset_reader queue can be // priority-ordered, so the one with the next relevant tile // is first in line. @@ -1037,9 +1037,9 @@ void decode(struct tileset_reader *readers, std::mapzoom != current.first.z || readers->x != current.first.x || readers->y != current.first.y) { - if (tasks.size() > 100 * CPUS) { - dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers); - tasks.clear(); + if (svks.size() > 100 * CPUS) { + dispatch_svks(svks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers); + svks.clear(); } } @@ -1067,7 +1067,7 @@ void decode(struct tileset_reader *readers, std::mapminlat2 = min(minlat, st->minlat2); st->maxlat2 = max(maxlat, st->maxlat2); - dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers); + dispatch_svks(svks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers); layermap = merge_layermaps(layermaps); struct tileset_reader *next; diff --git a/tile.cpp b/tile.cpp index 2e5cd7b0..4e8d0438 100644 --- a/tile.cpp +++ b/tile.cpp @@ -546,8 +546,8 @@ struct partial { struct partial_arg { std::vector *partials = NULL; - int task = 0; - int tasks = 0; + int svk = 0; + int svks = 0; drawvec *shared_nodes; node *shared_nodes_map; @@ -672,7 +672,7 @@ void *partial_feature_worker(void *v) { struct partial_arg *a = (struct partial_arg *) v; std::vector *partials = a->partials; - for (size_t i = a->task; i < (*partials).size(); i += a->tasks) { + for (size_t i = a->svk; i < (*partials).size(); i += a->svks) { double area = simplify_partial(&((*partials)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos); signed char t = (*partials)[i].t; @@ -1367,7 +1367,7 @@ long long choose_minextent(std::vector &extents, double f) { } struct write_tile_args { - struct task *tasks = NULL; + struct svk *svks = NULL; char *stringpool = NULL; int min_detail = 0; sqlite3 *outdb = NULL; @@ -2557,23 +2557,23 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch find_common_edges(partials, z, line_detail, simplification, maxzoom, merge_fraction); } - int tasks = ceil((double) CPUS / *running); - if (tasks < 1) { - tasks = 1; + int svks = ceil((double) CPUS / *running); + if (svks < 1) { + svks = 1; } - pthread_t pthreads[tasks]; + pthread_t pthreads[svks]; std::vector args; - args.resize(tasks); - for (int i = 0; i < tasks; i++) { - args[i].task = i; - args[i].tasks = tasks; + args.resize(svks); + for (int i = 0; i < svks; i++) { + args[i].svk = i; + args[i].svks = svks; args[i].partials = &partials; args[i].shared_nodes = &shared_nodes; args[i].shared_nodes_map = shared_nodes_map; args[i].nodepos = nodepos; - if (tasks > 1) { + if (svks > 1) { if (pthread_create(&pthreads[i], NULL, partial_feature_worker, &args[i]) != 0) { perror("pthread_create"); exit(EXIT_PTHREAD); @@ -2583,8 +2583,8 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch } } - if (tasks > 1) { - for (int i = 0; i < tasks; i++) { + if (svks > 1) { + for (int i = 0; i < svks; i++) { void *retval; if (pthread_join(pthreads[i], &retval) != 0) { @@ -3055,17 +3055,17 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch return -1; } -struct task { +struct svk { int fileno = 0; - struct task *next = NULL; + struct svk *next = NULL; }; void *run_thread(void *vargs) { write_tile_args *arg = (write_tile_args *) vargs; - struct task *task; + struct svk *svk; - for (task = arg->tasks; task != NULL; task = task->next) { - int j = task->fileno; + for (svk = arg->svks; svk != NULL; svk = svk->next) { + int j = svk->fileno; if (arg->geomfd[j] < 0) { // only one source file for zoom level 0 @@ -3275,11 +3275,11 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic< // Assign temporary files to threads - std::vector tasks; - tasks.resize(TEMP_FILES); + std::vector svks; + svks.resize(TEMP_FILES); struct dispatch { - struct task *tasks = NULL; + struct svk *svks = NULL; long long todo = 0; struct dispatch *next = NULL; }; @@ -3288,7 +3288,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic< struct dispatch *dispatch_head = &dispatches[0]; for (size_t j = 0; j < threads; j++) { - dispatches[j].tasks = NULL; + dispatches[j].svks = NULL; dispatches[j].todo = 0; if (j + 1 < threads) { dispatches[j].next = &dispatches[j + 1]; @@ -3302,9 +3302,9 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic< continue; } - tasks[j].fileno = j; - tasks[j].next = dispatch_head->tasks; - dispatch_head->tasks = &tasks[j]; + svks[j].fileno = j; + svks[j].next = dispatch_head->svks; + dispatch_head->svks = &svks[j]; dispatch_head->todo += geom_size[j]; struct dispatch *here = dispatch_head; @@ -3386,7 +3386,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic< args[thread].attribute_accum = attribute_accum; args[thread].filter = filter; - args[thread].tasks = dispatches[thread].tasks; + args[thread].svks = dispatches[thread].svks; args[thread].running = &running; args[thread].pass = pass; args[thread].wrote_zoom = -1;