Catalog: parallelize all-sky tile prefetch
This commit is contained in:
1 parent
d9f2c83b9f
commit
457c0728b4
10 files changed
+371
-55
No files matched your search
@@ -0,0 +1,7 @@
|
||||
# An inertial observer at the origin whose spatial camera triad scans RA 0, 20,
|
||||
# and 40 degrees at Dec -75 degrees. Samples coincide with a 1 fps movie so
|
||||
# this fixture avoids interpolation-induced non-orthonormal intermediate triads.
|
||||
t,tau,x,y,z,e0t,e0x,e0y,e0z,e1t,e1x,e1y,e1z,e2t,e2x,e2y,e2z,e3t,e3x,e3y,e3z
|
||||
0,0,0,0,0,1,0,0,0,0,0.25881904510252074,-0.9659258262890683,0,0,0.9659258262890683,0.25881904510252074,0,0,0,0,1
|
||||
1,1,0,0,0,1,0,0,0,0,0.24321034680169396,-0.9659258262890683,0.08852132690137686,0,0.9076733711903687,0.25881904510252074,0.33036608954935215,0,-0.3420201433256687,0,0.9396926207859084
|
||||
2,2,0,0,0,1,0,0,0,0,0.19826689127414615,-0.9659258262890683,0.1663656753428019,0,0.739942111693848,0.25881904510252074,0.6208851530148457,0,-0.6427876096865394,0,0.766044443118978
|
||||
|
@@ -0,0 +1,71 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include "catalog.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int write_tile(const char *directory, int ra_index, int dec_index,
|
||||
double longitude) {
|
||||
char path[4096];
|
||||
const int written = snprintf(path, sizeof path, "%s/tile_ra%03d_dec%03d.csv",
|
||||
directory, ra_index, dec_index);
|
||||
if (written < 0 || written >= (int)sizeof path)
|
||||
return -1;
|
||||
FILE *file = fopen(path, "w");
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
const int result =
|
||||
fputs("longitude_deg,latitude_deg,temperature_K,amplitude\n", file) == EOF ||
|
||||
fprintf(file, "%.1f,0,7000,1\n", longitude) < 0 ||
|
||||
fclose(file) != 0;
|
||||
return result ? -1 : 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
char directory[] = "/tmp/catalog_prefetch_XXXXXX";
|
||||
char path[4096];
|
||||
StarCatalog catalog = {0};
|
||||
unsigned char requested[CATALOG_ALL_SKY_TILE_COUNT] = {0};
|
||||
CatalogPrefetchStats first = {0}, second = {0};
|
||||
int result = 1;
|
||||
if (mkdtemp(directory) == NULL || write_tile(directory, 0, 90, 0.0) ||
|
||||
write_tile(directory, 1, 90, 1.0) ||
|
||||
catalog_load_all_sky(&catalog, directory))
|
||||
goto done;
|
||||
requested[90 * CATALOG_ALL_SKY_RA_TILES] = 1;
|
||||
requested[90 * CATALOG_ALL_SKY_RA_TILES + 1] = 1;
|
||||
requested[90 * CATALOG_ALL_SKY_RA_TILES + 2] = 1; /* Missing on purpose. */
|
||||
if (catalog_prefetch_marked_tiles(&catalog, requested, 4, &first) ||
|
||||
first.requested_tiles != 3 || first.newly_loaded_tiles != 2 ||
|
||||
first.unavailable_tiles != 1 || first.newly_loaded_stars != 2 ||
|
||||
catalog.count != 2 ||
|
||||
catalog.tiles[90 * CATALOG_ALL_SKY_RA_TILES].state != 1 ||
|
||||
catalog.tiles[90 * CATALOG_ALL_SKY_RA_TILES + 1].state != 1 ||
|
||||
catalog.tiles[90 * CATALOG_ALL_SKY_RA_TILES + 2].state != -1) {
|
||||
fputs("parallel catalog prefetch regression failed\n", stderr);
|
||||
goto done;
|
||||
}
|
||||
Star *first_tile = catalog.tiles[90 * CATALOG_ALL_SKY_RA_TILES].stars;
|
||||
if (catalog_prefetch_marked_tiles(&catalog, requested, 2, &second) ||
|
||||
second.requested_tiles != 3 || second.newly_loaded_tiles != 0 ||
|
||||
second.unavailable_tiles != 0 || second.newly_loaded_stars != 0 ||
|
||||
catalog.count != 2 ||
|
||||
catalog.tiles[90 * CATALOG_ALL_SKY_RA_TILES].stars != first_tile) {
|
||||
fputs("catalog prefetch cache reuse regression failed\n", stderr);
|
||||
goto done;
|
||||
}
|
||||
result = 0;
|
||||
done:
|
||||
catalog_destroy(&catalog);
|
||||
for (int ra = 0; ra < 3; ++ra) {
|
||||
const int written = snprintf(path, sizeof path, "%s/tile_ra%03d_dec090.csv",
|
||||
directory, ra);
|
||||
if (written > 0 && written < (int)sizeof path)
|
||||
unlink(path);
|
||||
}
|
||||
rmdir(directory);
|
||||
return result;
|
||||
}
|
||||
+4
-4
@@ -27,7 +27,7 @@ int main(void) {
|
||||
goto done;
|
||||
const size_t images =
|
||||
frame_splat_catalog(&mesh, &catalog, hdr, width, height, test_exposure,
|
||||
&psf);
|
||||
&psf, 1, NULL);
|
||||
if (images != 1 || hdr[3 * (50 * width + 50)] <= 0.0) {
|
||||
fputs("flat-space inverse lens-map regression failed\n", stderr);
|
||||
goto done;
|
||||
@@ -44,10 +44,10 @@ int main(void) {
|
||||
omp_set_dynamic(0);
|
||||
omp_set_num_threads(1);
|
||||
const size_t serial_images = frame_splat_catalog(
|
||||
&mesh, &catalog, serial_hdr, width, height, test_exposure, &psf);
|
||||
&mesh, &catalog, serial_hdr, width, height, test_exposure, &psf, 1, NULL);
|
||||
omp_set_num_threads(4);
|
||||
const size_t parallel_images = frame_splat_catalog(
|
||||
&mesh, &catalog, parallel_hdr, width, height, test_exposure, &psf);
|
||||
&mesh, &catalog, parallel_hdr, width, height, test_exposure, &psf, 1, NULL);
|
||||
omp_set_num_threads(original_threads);
|
||||
for (int value = 0; value < width * height * 3; ++value)
|
||||
if (fabs(serial_hdr[value] - parallel_hdr[value]) >
|
||||
@@ -102,7 +102,7 @@ int main(void) {
|
||||
if (frame_lens_mesh_build_coarse(&fine_mesh, width, height, 1, 0.1) ||
|
||||
frame_lens_mesh_trace(&fine_mesh, &spacetime, &observer, &trace) ||
|
||||
frame_splat_catalog(&fine_mesh, &fine_catalog, hdr, width, height,
|
||||
test_exposure, &psf) != 1) {
|
||||
test_exposure, &psf, 1, NULL) != 1) {
|
||||
fputs("fine source-triangle containment regression failed\n", stderr);
|
||||
frame_lens_mesh_destroy(&fine_mesh);
|
||||
goto done;
|
||||
|
||||
Reference in new issue
Block a user