Skip to content

Fix distance L1 dispatch and add -fPIC to shared library builds - #1

Merged
balbasty merged 3 commits into
mainfrom
claude/jitfields-fastfields-migration-v5r416
Jul 20, 2026
Merged

Fix distance L1 dispatch and add -fPIC to shared library builds#1
balbasty merged 3 commits into
mainfrom
claude/jitfields-fastfields-migration-v5r416

Conversation

@balbasty

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes two bugs in the fastfields library and adds comprehensive migration documentation.

Key Changes

Bug Fixes

  • distance.cpp: Fixed incorrect dispatch in dt_l1() which was calling dt_euclidean instead of dt_l1 for both CPU and CUDA paths
  • Makefile: Added -fPIC flag to object compilation rule to fix shared library linking failures (relocation R_X86_64_PC32 errors)

Documentation

  • MIGRATION.md (new): Added comprehensive migration status and planning document including:
    • Layer architecture recap for the DLPack-based fastfields library
    • Status matrix tracking port completion across 8 modules (distance, posdef, pushpull, etc.)
    • Build and test instructions for CPU path
    • Detailed list of bugs found and fixed during porting
    • Known unfixed bugs requiring CUDA toolchain verification
    • Porting pattern template for future modules
    • Task breakdown for remaining work (T3-T7)

Implementation Details

The dt_l1 dispatch bug was a copy-paste error where both the CUDA and CPU branches incorrectly called dt_euclidean. The fix ensures the L1 distance transform is actually invoked when requested.

The -fPIC flag is necessary for position-independent code in shared libraries; its absence caused linker failures when building libfastfields.so and libfastfields-cpu.so.

https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z

claude added 3 commits July 20, 2026 10:12
- distance.cpp: dt_l1 called FF_CUDA/FF_CPU::dt_euclidean instead of
dt_l1 in both device branches, so the L1 transform was never invoked.
- Makefile: object compile rule was missing -fPIC (shared-lib link failure).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
Documents the layered DLPack port, the per-module status across layers,
the CPU bugs fixed this pass, two CUDA/spline bugs found but not yet
verifiable here, the per-module porting pattern, and a task breakdown.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
Public ff:: sym_matvec[_backward], sym_addmatvec_, sym_submatvec_,
sym_solve[_], sym_invert[_] taking DLTensor, dispatching on device to the
cpu/cuda libs (cuda guarded by FF_WITH_CUDA). Makefile: add posdef to
MODULES (CPU-only build links; the cuda branch is compiled only under
FF_WITH_CUDA).
@balbasty
balbasty merged commit b5681df into mainJul 20, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@balbasty@claude