doe300 / VC4CL

OpenCL implementation running on the VideoCore IV GPU of the Raspberry Pi models
MIT License
728 stars 80 forks source link

Test emulation of hardware access #52

Closed disdi closed 5 years ago

disdi commented 5 years ago

@doe300

The below commit adds emulation support -

https://github.com/doe300/VC4CL/commit/80f94cc9421c65e9408beea109c314a5df4cf23d

What are the steps to emulate this on x86 machine ?

doe300 commented 5 years ago

You'll need to compile the VC4CL project with compiler support and MOCK_HAL enabled.

To run the programs, you will need to circumvent the OpenCL ICD loader, e.g. by creating a sym-linked libOpenCL.so which points to the libVC4CL.so and link against that or use LD_LIBRARY_PATH/LD_PRELOAD to inject the OpenCL library, e.g. (from the top of my head, not actually tested):

# build VC4CL with MOCK_HAL enabled
cd /path/to/VC4CL/build/
cmake -DMOCK_HAL=ON ../
make -j$(nproc) VC4CL
# run program with emulated hardware
ln -s ./src/libVC4CL.so libOpenCL.so
LD_PRELOAD=./libOpenCL.so /your/program

At the moment, I do not know whether the emulation works correctly, since I am still improving and testing it. But I could reproduce the results of the hardware for some boost/compute test-cases.