Comments (8)
We do have basic C API support equivalent to XRT native C++ API support. However, we dont enhance or add new C API request. We encourage using C++ API, you can make any C++ API to C API by writing your own wrapper, this what we recommend.
But if you still would like to see the basic C APIs you can see them in our old documentation:
https://xilinx.github.io/XRT/2020.2/html/xrt_native_apis.html
Thanks
from xrt.
Thank you. This is useful! I would also like to know if there is a way to do memory allocation, data transfer, kernel launch in the Linux kernel space? I saw there are a bunch of ioctl calls listed in the documents, and I saw the following flow:
Execution FlowΒΆ
A typical user execution flow would like the following:
Load xclbin using DOWNLOAD ioctl
Discover compute unit register map from xclbin
Allocate data buffers to feed to the compute units using CREATE_BO/MAP_BO ioctl calls
Migrate input data buffers from host to device using SYNC_BO ioctl
Allocate an execution command buffer using CREATE_BO/MAP_BO ioctl call and fill the command buffer using data in 2 above and following the format defined in ert.h
Submit the execution command buffer using EXECBUF ioctl
Wait for completion using POSIX poll
Migrate output data buffers from device to host using SYNC_BO ioctl
Release data buffers and command buffer
Are there sample codes provided somewhere?
Thanks & Regards
from xrt.
no, those IOCTL driver-level details are internal descriptions, and not for the end-user.
For end-user we support User-space APIs (XRT native C++ API, and XRT native C API to some extent).
That said, XRT is open source and you can look at any IOCTL code, but those are not something we expect end-user to do anything, and using them could be using at your own risk.
from xrt.
Ok, that makes sense to me.
There are just a couple of things I would like to confirm:
- When dealing with buffer data transfer, the XDMA driver is used for DMA. For writing registers of an FPGA kernel, MMIO will be used. Is this correct?
- data migration starts/ends in the kernel space in either direction(device to host/host to device). With that being said, for the host application to send/receive data to/from the device, there is one data copy needed between Linux userspace and kernel space. Correct me if I am wrong.
Thanks & Regards
from xrt.
- Correct
- Incorrect. User-space access the buffers, allocated by the driver through the pointer. So there is no additional copy between user-space and driver-space
from xrt.
Something is still confused to me. It looks like the data transfer completely bypass the kernel?
I just want to figure out what actually happened when an OpenCL Buffer object or xrt::bo object is created. Based on what you said, those buffers are allocated by the driver through a pointer in the kernel, and they essentially reside in the user-space. So for any data transfer between host and device, data is directly copied between host user-space and device-space. Are those memory buffers visible to the kernel? One way I know to achieve such a zero-copy is that you have a shared memory space between user and kernel space, and then malloc a buffer in the user-space and update in the kernel page table will allow the kernel to access this memory buffer?
What was actually happened under the hood when we create a device buffer here? I really appreciate your help!
Thanks!
from xrt.
When we ask XRT to create a BO, then the driver (kernel space) allocates memory both in the Host System Memory and also in the device Memory. When doing bo::sync
operation then DMA happens through PCIe so that synchronization happens between the Host Memory and Device Memory. After creating BO, user-space calls the MAP function (bo::map
) to get the pointer by which it access the data (for reading or writing)
from xrt.
Back up a bit. When you mentioned Host System Memory, does it mean a shared memory region that is visible to both user-space and kernel-space? What I am not understanding is where is the memory allocated by the driver? In the Linux kernel or user space? (This is important because if it is in the kernel space, user-space application has no way to directly access it to the best of my knowledge except that the memory region is shared across user and kernel space, and a data copy will degrade performance)
Then the second question: Is the allocated memory for BO a shared memory?
from xrt.
Related Issues (20)
- XRT build.sh fails on xocl using ubuntu 22.04 kernel ver 6.5 HOT 6
- pybind11-dev package is ignored on Ubuntu 22.04
- Coexistence of OpenCL and XRT APIs and long-term support HOT 2
- XRT uses `rapidjson-dev` which does not compile on Ubuntu 24.04
- Confused about whether my npu is working properly or not.
- U250: DMA test failed
- xbutil examine 0 devices found
- Documentation Fix
- Details: bins/1502_00/validate.xclbin not available. Skipping validation. HOT 1
- Issues Compiling XRT on Linsat v2.4.5 (Based on Debian 10) for Zynq UltraScale DPU Implementation
- pyxrt not compatible with numpy v2.0.0
- Symbol lookup error in `XRT/build/Debug/runtime_src/core/tools/xbutil2xrt-smi` HOT 1
- Can't convert xrt::aie::bo to xrt::bo HOT 4
- Release XRT tools on modules
- build only xbflash2 tool HOT 1
- Ubuntu build failure: please include stdint.h header HOT 1
- any plan to provide xrt deb package for ubuntu 24.04?
- any plan to provide xrt deb package for ubuntu 24.04?
- 403 Forbidden during install attempt using apt HOT 4
- Having difficulting installing local-built XRT with Ubuntu 22.04 kernel version 6.8.0-40-generic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xrt.