KhronosGroup / KhronosGroup/OpenCL-Docs

Calling a Kernel Function in a Separately Compiled Program

Open
#675 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
421
Forks
132
Avg merge
5d 13h
Merged PRs (30d)
11

Description

Creating this issue from a discussion in a SPIRV-LLVM-Translator PR review:

https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/1149#discussion_r707417308

In short, the question is: can a function in one program call a kernel function in another program?

Here is the example from the PR discussion:

// source 1
void foo(global int *_B);     
void kernel A(global int *B) {
  foo(B);                     
}
// source 2
void kernel foo(global int *B) {
  B[0] = 1;
}

This came about because the SPIR-V spec states that "It is invalid for any function to be targeted by both an OpEntryPoint instruction and an OpFunctionCall instruction." The SPIR-V LLVM Translator PR solves this by introducing an "entry point wrapper" around a kernel function that is also called as an ordinary function then fixing up the calls to the kernel function in the program. This works for callers in the same program, but it won't work for callers in other programs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked SPIRV-LLVM-Translator PR discussion and the quoted SPIR-V rule about OpEntryPoint and OpFunctionCall. Determine whether a kernel function in one separately compiled program may be called from another, and document a definitive answer or the required specification clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.