Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xe: enable source code information for OpenCL kernels #2339

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rjoursler
Copy link
Contributor

As the difficult case for handling nGEN was already handled in #2297, it seems only fitting to enable debug information in the simpler case where we use OpenCL C kernels. This PR limits the scope of support for this to Linux due to the nuances required for handling temporary files. It should be fairly easy to extend with Windows support when it becomes useful.

@rjoursler rjoursler requested review from a team as code owners January 3, 2025 23:33
@github-actions github-actions bot added platform:gpu-intel Codeowner: @oneapi-src/onednn-gpu-intel component:build labels Jan 3, 2025
@rjoursler
Copy link
Contributor Author

make test
disable device_cpu
enable device_gpu

@@ -46,6 +46,11 @@ endfunction()
function(gen_gpu_kernel_list ker_list_templ ker_list_src ker_sources headers)
set(_sources "${SOURCES}")

set(MINIFY "ON")
if(DNNL_DEV_MODE OR CMAKE_BUILD_TYPE STREQUAL "Debug")
set(MINIFY "OFF")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this impact compile time or does it impact library size only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing, I do not see any measurable impact on compilation time.


const int name_size = 29;
char name[name_size] = "/tmp/dnnl_ocl_jit_src.XXXXXX";
int fd = mkstemp(name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avmanerikar @vpirogov

Is creating temporary files this way compatible with our SDL?

@@ -249,6 +250,9 @@ status_t ocl_gpu_engine_t::build_program_from_source(
std::string pp_code_str = pp_code.str();
const char *pp_code_str_ptr = pp_code_str.c_str();

src = {pp_code_str};
if (src) { options += " -g -s " + std::string(src.name()); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you clarify what the -s options does here, I could not find it in opencl list of options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -249,6 +250,9 @@ status_t ocl_gpu_engine_t::build_program_from_source(
std::string pp_code_str = pp_code.str();
const char *pp_code_str_ptr = pp_code_str.c_str();

src = {pp_code_str};
if (src) { options += " -g -s " + std::string(src.name()); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be the only place where program_src_t is needed.
Why introduce program_src_t, and not do everything in this function directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal here is that this file is temporary and is deleted after it is no longer necessary. In particular, this means that this file is necessary so long the resulting compute::kernels is instantiated, so that this file can be referenced by a debugger. The program_src_t structure is largely responsible for handling this lifetime management. We will also need a similar file if we are to introduce debug information for our ir based kernels as currently all nGEN debug information just maps to the code which lowers the IR to nGEN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:build platform:gpu-intel Codeowner: @oneapi-src/onednn-gpu-intel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants