Java Interface & Coherency
lucapiccolboni opened this issue · comments
Hi,
First, thank you so much for open-sourcing the code. It's super useful!
I created a Java interface to use the device driver and call a hardware accelerator. The Java interface is similar to the one that you pushed as an example for Python. Unfortunately, I have some coherency issues. I created the memory mapping in Java in the following way:
String path = "/dev/udmabuf" + String.valueOf(id);
RandomAccessFile file = new RandomAccessFile(path, "rw");
buffer = file.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, bytes);
I set sync_mode
to 0 and sync_direction
to 0. The accelerator does not support coherency. Thus, I used sync_for_cpu
and sync_for_device
to ensure the coherency with the CPU. When I write data from the CPU it seems to work properly. The accelerator reads the correct input data. When the accelerator writes, however, the CPU does not always read the data correctly. When the input and output data that I send to the accelerator are small, it can actually read the correct the values. When the input and output become bigger in size, the CPU reads old values for some reasons. The sizes of the data is always less than the entire size of the UDMA buffer.
I am running on an ARM64 architecture (Xilinx ZCU102).
Do you have any idea what could be the issue?
I think I figured it out. Please delete this issue. Thanks.