Add Linux userspace & kernel driver support for CGRA4ML#20
Open
JDRadatti wants to merge 40 commits into
Open
Conversation
and shell.json for kernel build
The baremetal runtime.h assumes virtual==physical addressing and
direct register access, which breaks under Linux's virtual memory.
Add deepsocflow_linux.h — a preprocessor-based adapter that redirects
register accesses through driver IOCTLs and places the Memory_st
struct inside the DMA-coherent weights buffer so hardware and CPU
share the same physical memory without copying.
Also:
- Guard fb_fw_wrap.h baremetal definitions behind
DEEPSOCFLOW_LINUX_OVERRIDE to avoid macro-recursion during
compilation
- Add inference test app (linux_test/inference.c) that loads
wbx.bin, runs the full bundle loop, and prints results
- Update linux_test/Makefile to build inference with -lm
- deepsocflow/c/host.c: exports host_setup() and host_cleanup() which open /dev/cgra4ml, GET_BUFS ioctl, mmap DMA buffer, load wbx.bin - linux_test/inference.c: updated to call host_setup/host_cleanup - linux_test/Makefile: build libinference.so from host.c - python/run_inference.py: new ctypes runner calling host_setup/run/print_output/host_cleanup - deepsocflow/c/linux_inference.c: removed (replaced by host.c)
- make bundle: builds libinference.so + test binaries, copies libinference.so, inference, run_inference.py, cgra4ml_drv.ko, and wbx.bin into deploy/ for a single scp -r deploy/ command
- git mv linux_driver deepsocflow/linux/driver - Update Makefile driver targets to new path - Update .gitignore patterns
- git mv linux_test deepsocflow/linux/test - Update test Makefile include paths (now one level deeper) - Update top-level Makefile test_app and bundle targets - Update .gitignore patterns
- git mv python/run_inference.py deepsocflow/linux/runner.py - Update Makefile bundle target path
- Delete cgra4ml_pynq.py (dead code, replaced by ctypes-based runner.py) - Delete python_README.md (documented the removed file)
- Update main README.md paths (linux_driver → deepsocflow/linux/driver, linux_test → deepsocflow/linux/test) - Rename linux_driver_README.md → README.md - Rename linux_test_README.md → README.md - Update internal path references in both READMEs
Per the reorganization plan, host.c (Linux platform initialization) belongs in deepsocflow/linux/ alongside the other Linux-specific code, not in deepsocflow/c/ which contains platform-agnostic firmware. - git mv deepsocflow/c/host.c deepsocflow/linux/host.c - Update deepsocflow/linux/test/Makefile: ../../c/host.c → ../host.c
- Add 'make linux' target that builds driver + bundle in one command - Remove 'driver_install' target (user prefers manual scp) - Update .PHONY declarations - Print deployment instructions after build New workflow: make hw # Build bitstream (already done) make linux # Build everything + create deploy/ # Manual deployment: scp deepsocflow/linux/driver/cgra4ml_drv.ko amd-edf@192.168.2.10:/tmp/ scp -r deploy amd-edf@192.168.2.10:/home/amd-edf/
Change run/work/wbx.bin to run/work/vectors/wbx.bin to match the actual location where the model generator places the file.
- Updated Makefile, .gitignore to match - deepsocflow/linux/test/inference.c -> deepsocflow/linux/linux_example.c - deepsocflow/linux/runner.py -> deepsocflow/linux/linux_example.py
- Moved linux logic to /deepsocflow/linux/Makefile - Fixed `overlay` target which enabled removing fragile sed commands - Other minor fixes Some things still need cleaning: - EDF_OVERLAY_TARGET is hardcoded - PROJECT_NAME is redefined - BOARDSTORE_BRANCH is hardcoded
Update scp command to store in fpga's home directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
This PR adds Linux support for CGRA4ML, enabling inference on the CGRA accelerator from a Linux userspace application on a Zynq FPGA. It introduces a kernel driver with IOCTL-based register access and DMA-coherent buffer management, a userspace platform adapter that overrides the bare-metal runtime.h macros, a shared library (libinference.so), C/Python examples, and a test suite.
CHANGES
New: Linux Kernel Driver (deepsocflow/linux/driver/)
New: Linux Userspace Adapter (deepsocflow/c/deepsocflow_linux.h)
New: Host Initialization (deepsocflow/linux/host.c)
New: Build System (deepsocflow/linux/Makefile)
make linuxtarget for the full buildNew: Examples
New: Test Suite (deepsocflow/linux/test/)
Other fixes & improvements
ORGANIZATION
TODO
NEED TO FIX
Contributors:
@allan70627
@JDRadatti