Skip to content

Conversation

@echuraev
Copy link
Contributor

@echuraev echuraev commented Sep 14, 2023

After adding OpenCL wrapper, it is possible to build TVM with OpenCL support also on the host which doesn't have OpenCL libraries. But if you want to compile OpenCL module for a remote device on such host machine then you will see an error that OpenCL lib cannot be open.

To avoid such problem, we need to call OpenCL functions only in runtime. So function for initializing OpenCL workspace was removed from OpenCLModuleNode. And a new function IsProgramCreated was added. The last function is necessary to prepare vectors with OpenCL programs, associated with OpenCL devices. Previously it was done during OpenCLModule initialization. So, now we create such vectors only in runtime after getting list of available OpenCL devices.

@echuraev
Copy link
Contributor Author

cc: @elvin-n

After adding OpenCL wrapper, it is possible to build TVM with OpenCL
support also on the host which doesn't have OpenCL libraries. But if
you want to compile OpenCL module for a remote device on such host
machine then you will see an error that OpenCL lib cannot be open.

To avoid such problem, we need to call OpenCL functions only in
runtime. So function for initializing OpenCL workspace was removed from
OpenCLModuleNode. And a new function `IsProgramCreated` was added. The
last function is necessary to prepare vectors with OpenCL programs,
associated with OpenCL devices. Previously it was done during
OpenCLModule initialization. So, now we create such vectors only
in runtime after getting list of available OpenCL devices.
@echuraev echuraev force-pushed the echuraev/do_not_initialize_opencl_on_host branch from f1ad8d0 to 4b8c06f Compare September 15, 2023 13:30
@echuraev
Copy link
Contributor Author

@masahi, @elvin-n Could you please review?

@masahi masahi merged commit ae89c1e into apache:main Sep 25, 2023
vinx13 pushed a commit to vinx13/tvm that referenced this pull request Oct 17, 2023
* [OpenCL] Don't initialize OpenCL runtime on host

After adding OpenCL wrapper, it is possible to build TVM with OpenCL
support also on the host which doesn't have OpenCL libraries. But if
you want to compile OpenCL module for a remote device on such host
machine then you will see an error that OpenCL lib cannot be open.

To avoid such problem, we need to call OpenCL functions only in
runtime. So function for initializing OpenCL workspace was removed from
OpenCLModuleNode. And a new function `IsProgramCreated` was added. The
last function is necessary to prepare vectors with OpenCL programs,
associated with OpenCL devices. Previously it was done during
OpenCLModule initialization. So, now we create such vectors only
in runtime after getting list of available OpenCL devices.

* Call workspace init function before all OpenCL API calls
Sign up for free to 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.

3 participants