Makefile: add Debug build diagnostics
This commit is contained in:
1 parent
9e22d59213
commit
6f8ec50c64
3 files changed
+65
-26
No files matched your search
@@ -1,9 +1,20 @@
|
|||||||
CC ?= cc
|
CC ?= cc
|
||||||
CFLAGS ?= -std=c11 -march=native -O2 -pipe -Wall -Wextra -Wpedantic
|
CFLAGS ?= -std=c11 -march=native -pipe -Wall -Wextra -Wpedantic
|
||||||
OPENMP_FLAGS ?= -fopenmp
|
OPENMP_FLAGS ?= -fopenmp
|
||||||
LDLIBS ?= -lm
|
LDLIBS ?= -lm
|
||||||
ENABLE_PNG ?= 1
|
ENABLE_PNG ?= 1
|
||||||
SPACETIME ?= minkowski
|
SPACETIME ?= minkowski
|
||||||
|
BUILD_TYPE ?= Release
|
||||||
|
|
||||||
|
ifeq ($(BUILD_TYPE),Release)
|
||||||
|
BUILD_CFLAGS := -O2 -DNDEBUG
|
||||||
|
BUILD_CPPFLAGS :=
|
||||||
|
else ifeq ($(BUILD_TYPE),Debug)
|
||||||
|
BUILD_CFLAGS := -O0 -g3
|
||||||
|
BUILD_CPPFLAGS := -DGR_DEBUG
|
||||||
|
else
|
||||||
|
$(error Unknown BUILD_TYPE '$(BUILD_TYPE)'; choose Release or Debug)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_PNG),1)
|
ifeq ($(ENABLE_PNG),1)
|
||||||
CPPFLAGS += -DENABLE_PNG
|
CPPFLAGS += -DENABLE_PNG
|
||||||
@@ -15,14 +26,15 @@ endif
|
|||||||
|
|
||||||
COMMON_SOURCES := $(filter-out src/main.c src/spacetime_minkowski.c src/spacetime_schwarzschild.c,$(wildcard src/*.c))
|
COMMON_SOURCES := $(filter-out src/main.c src/spacetime_minkowski.c src/spacetime_schwarzschild.c,$(wildcard src/*.c))
|
||||||
PROVIDER_SOURCE := src/spacetime_$(SPACETIME).c
|
PROVIDER_SOURCE := src/spacetime_$(SPACETIME).c
|
||||||
TARGET := build/$(SPACETIME)_sky
|
BUILD_DIR := build/$(BUILD_TYPE)
|
||||||
|
TARGET := $(BUILD_DIR)/$(SPACETIME)_sky
|
||||||
CORE_MINKOWSKI_SOURCES := $(COMMON_SOURCES) src/spacetime_minkowski.c
|
CORE_MINKOWSKI_SOURCES := $(COMMON_SOURCES) src/spacetime_minkowski.c
|
||||||
TEST_TARGET := build/test_geodesic
|
TEST_TARGET := $(BUILD_DIR)/test_geodesic
|
||||||
FRAME_TEST_TARGET := build/test_frame
|
FRAME_TEST_TARGET := $(BUILD_DIR)/test_frame
|
||||||
SCHWARZSCHILD_TEST_TARGET := build/test_schwarzschild
|
SCHWARZSCHILD_TEST_TARGET := $(BUILD_DIR)/test_schwarzschild
|
||||||
OBSERVER_TRACK_TEST_TARGET := build/test_observer_track
|
OBSERVER_TRACK_TEST_TARGET := $(BUILD_DIR)/test_observer_track
|
||||||
CATALOG_PREFETCH_TEST_TARGET := build/test_catalog_prefetch
|
CATALOG_PREFETCH_TEST_TARGET := $(BUILD_DIR)/test_catalog_prefetch
|
||||||
PSF_HDR_TEST_TARGET := build/minkowski_psf_hdr_test
|
PSF_HDR_TEST_TARGET := $(BUILD_DIR)/minkowski_psf_hdr_test
|
||||||
|
|
||||||
.PHONY: all clean run test minkowski schwarzschild psf-hdr-test
|
.PHONY: all clean run test minkowski schwarzschild psf-hdr-test
|
||||||
|
|
||||||
@@ -36,10 +48,10 @@ endif
|
|||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(COMMON_SOURCES) $(PROVIDER_SOURCE) src/main.c | build
|
$(TARGET): $(COMMON_SOURCES) $(PROVIDER_SOURCE) src/main.c | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(BACKEND_CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(BACKEND_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
build:
|
$(BUILD_DIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
run: $(TARGET)
|
run: $(TARGET)
|
||||||
@@ -53,25 +65,25 @@ schwarzschild:
|
|||||||
$(MAKE) SPACETIME=schwarzschild all
|
$(MAKE) SPACETIME=schwarzschild all
|
||||||
|
|
||||||
# Deliberately separate from the production binary: enables --hdr-output FITS.
|
# Deliberately separate from the production binary: enables --hdr-output FITS.
|
||||||
$(PSF_HDR_TEST_TARGET): $(COMMON_SOURCES) src/spacetime_minkowski.c src/main.c | build
|
$(PSF_HDR_TEST_TARGET): $(COMMON_SOURCES) src/spacetime_minkowski.c src/main.c | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) -DENABLE_HDR_DEBUG -DSPACETIME_MINKOWSKI $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) $(shell pkg-config --libs cfitsio) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) -DENABLE_HDR_DEBUG -DSPACETIME_MINKOWSKI $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) $(shell pkg-config --libs cfitsio) -o $@
|
||||||
|
|
||||||
psf-hdr-test: $(PSF_HDR_TEST_TARGET)
|
psf-hdr-test: $(PSF_HDR_TEST_TARGET)
|
||||||
|
|
||||||
$(TEST_TARGET): tests/test_geodesic.c $(CORE_MINKOWSKI_SOURCES) | build
|
$(TEST_TARGET): tests/test_geodesic.c $(CORE_MINKOWSKI_SOURCES) | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(FRAME_TEST_TARGET): tests/test_frame.c $(CORE_MINKOWSKI_SOURCES) | build
|
$(FRAME_TEST_TARGET): tests/test_frame.c $(CORE_MINKOWSKI_SOURCES) | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(SCHWARZSCHILD_TEST_TARGET): tests/test_schwarzschild.c $(COMMON_SOURCES) src/spacetime_schwarzschild.c | build
|
$(SCHWARZSCHILD_TEST_TARGET): tests/test_schwarzschild.c $(COMMON_SOURCES) src/spacetime_schwarzschild.c | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(OBSERVER_TRACK_TEST_TARGET): tests/test_observer_track.c $(COMMON_SOURCES) | build
|
$(OBSERVER_TRACK_TEST_TARGET): tests/test_observer_track.c $(COMMON_SOURCES) | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(CATALOG_PREFETCH_TEST_TARGET): tests/test_catalog_prefetch.c $(CORE_MINKOWSKI_SOURCES) | build
|
$(CATALOG_PREFETCH_TEST_TARGET): tests/test_catalog_prefetch.c $(CORE_MINKOWSKI_SOURCES) | $(BUILD_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
test: $(TEST_TARGET) $(FRAME_TEST_TARGET) $(SCHWARZSCHILD_TEST_TARGET) $(OBSERVER_TRACK_TEST_TARGET) $(CATALOG_PREFETCH_TEST_TARGET)
|
test: $(TEST_TARGET) $(FRAME_TEST_TARGET) $(SCHWARZSCHILD_TEST_TARGET) $(OBSERVER_TRACK_TEST_TARGET) $(CATALOG_PREFETCH_TEST_TARGET)
|
||||||
./$(TEST_TARGET)
|
./$(TEST_TARGET)
|
||||||
|
|||||||
+20
-3
@@ -6,6 +6,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -780,6 +781,7 @@ static int owns_source_boundary(const LensTriangle *triangle,
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
const LensVertex *vertex[3];
|
const LensVertex *vertex[3];
|
||||||
const LensTriangle *triangle;
|
const LensTriangle *triangle;
|
||||||
|
size_t triangle_index;
|
||||||
double *hdr;
|
double *hdr;
|
||||||
int width, height;
|
int width, height;
|
||||||
double exposure, magnification;
|
double exposure, magnification;
|
||||||
@@ -820,10 +822,24 @@ static int splat_catalog_tile(const Star *stars, size_t count,
|
|||||||
weights[1] * context->vertex[1]->log_frequency_ratio +
|
weights[1] * context->vertex[1]->log_frequency_ratio +
|
||||||
weights[2] * context->vertex[2]->log_frequency_ratio;
|
weights[2] * context->vertex[2]->log_frequency_ratio;
|
||||||
const LinearRgb color = blackbody_to_linear_rgb(star->temperature_K * exp(log_g));
|
const LinearRgb color = blackbody_to_linear_rgb(star->temperature_K * exp(log_g));
|
||||||
context->direct_fallbacks += splat_moffat_cached(
|
const double flux = context->exposure * star->amplitude * context->magnification;
|
||||||
|
const int direct_fallback = splat_moffat_cached(
|
||||||
context->hdr, context->width, context->height, image_x, image_y, color,
|
context->hdr, context->width, context->height, image_x, image_y, color,
|
||||||
context->exposure * star->amplitude * context->magnification,
|
flux,
|
||||||
context->psf, context->psf_cache);
|
context->psf, context->psf_cache);
|
||||||
|
context->direct_fallbacks += direct_fallback;
|
||||||
|
#ifdef GR_DEBUG
|
||||||
|
if (direct_fallback)
|
||||||
|
/* This is deliberately emitted by the active splat worker: a direct
|
||||||
|
* fallback can be the long-running work a Debug render is waiting on.
|
||||||
|
* Do not add a critical section here; interleaved Debug lines are more
|
||||||
|
* useful than stalling the other workers. */
|
||||||
|
fprintf(stderr,
|
||||||
|
"Debug: %.3f s splat worker %d triangle %zu star %zu uses direct "
|
||||||
|
"PSF fallback (image %.3f, %.3f; flux %.6g).\n",
|
||||||
|
omp_get_wtime(), omp_get_thread_num(), context->triangle_index,
|
||||||
|
s, image_x, image_y, flux);
|
||||||
|
#endif
|
||||||
++context->images;
|
++context->images;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -853,7 +869,8 @@ static size_t splat_catalog_triangles(const FrameLensMesh *mesh,
|
|||||||
{vertex[1]->n_infinity[0], vertex[1]->n_infinity[1], vertex[1]->n_infinity[2]},
|
{vertex[1]->n_infinity[0], vertex[1]->n_infinity[1], vertex[1]->n_infinity[2]},
|
||||||
{vertex[2]->n_infinity[0], vertex[2]->n_infinity[1], vertex[2]->n_infinity[2]}};
|
{vertex[2]->n_infinity[0], vertex[2]->n_infinity[1], vertex[2]->n_infinity[2]}};
|
||||||
TriangleSplatContext context = {.vertex = {vertex[0], vertex[1], vertex[2]},
|
TriangleSplatContext context = {.vertex = {vertex[0], vertex[1], vertex[2]},
|
||||||
.triangle = &mesh->triangles[t], .hdr = hdr,
|
.triangle = &mesh->triangles[t],
|
||||||
|
.triangle_index = t, .hdr = hdr,
|
||||||
.width = width, .height = height,
|
.width = width, .height = height,
|
||||||
.exposure = exposure, .magnification = magnification,
|
.exposure = exposure, .magnification = magnification,
|
||||||
.psf = psf, .psf_cache = psf_cache};
|
.psf = psf, .psf_cache = psf_cache};
|
||||||
|
|||||||
+10
@@ -137,6 +137,12 @@ static int parse_args(int argc, char **argv, Settings *s,
|
|||||||
*s = (Settings){.width = 1280,
|
*s = (Settings){.width = 1280,
|
||||||
.height = 720,
|
.height = 720,
|
||||||
.coarse_cell_pixels = 16,
|
.coarse_cell_pixels = 16,
|
||||||
|
#ifdef GR_DEBUG
|
||||||
|
/* Debug builds make existing low-frequency render progress
|
||||||
|
* visible by default. Their worker heartbeats are local
|
||||||
|
* 8/16/32... milestones, not shared progress counters. */
|
||||||
|
.verbose = 1,
|
||||||
|
#endif
|
||||||
.horizontal_fov_deg = 30.0,
|
.horizontal_fov_deg = 30.0,
|
||||||
.look_ra_deg = 270.0,
|
.look_ra_deg = 270.0,
|
||||||
.look_dec_deg = 0.0,
|
.look_dec_deg = 0.0,
|
||||||
@@ -651,6 +657,10 @@ int main(int argc, char **argv) {
|
|||||||
argv[0]);
|
argv[0]);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
#ifdef GR_DEBUG
|
||||||
|
fputs("Debug build: low-frequency render progress is enabled; direct PSF "
|
||||||
|
"fallbacks log immediately from their splat worker.\n", stderr);
|
||||||
|
#endif
|
||||||
if (write_path != NULL)
|
if (write_path != NULL)
|
||||||
return catalog_write_octant_grid(write_path) == 0 ? 0
|
return catalog_write_octant_grid(write_path) == 0 ? 0
|
||||||
: (perror(write_path), 1);
|
: (perror(write_path), 1);
|
||||||
|
|||||||
Reference in new issue
Block a user