oneapi-src / level-zero

oneAPI Level Zero Specification Headers and Loader
https://spec.oneapi.com/versions/latest/elements/l0/source/index.html
MIT License
208 stars 90 forks source link

Add level-zero.pc #50

Closed bgoglin closed 3 years ago

bgoglin commented 3 years ago

Compiling against level-zero is currently inconvenient because headers are under include/level_zero instead of include. One has to manually change CPPFLAGS to find them. This PR adds a level-zero.pc on top of libze_loader.pc to make things easy.

Note that the CMake code might be suboptimal but at least it returns what I need for building hwloc with L0 support:

$ export PKG_CONFIG_PATH=$PWD/install/lib/pkgconfig/
$ pkg-config level-zero --cflags
-I/home/bgoglin/SOFT/oneapi/level-zero/build/install/include/level_zero -I/home/bgoglin/SOFT/oneapi/level-zero/build/install/include
$ pkg-config level-zero --libs  
-L/home/bgoglin/SOFT/oneapi/level-zero/build/install/lib -lze_loader

Signed-off-by: Brice Goglin Brice.Goglin@inria.fr

bmyates commented 3 years ago

Thanks, looks good

bgoglin commented 3 years ago

I was told by some L0 developers that the recommended way is to #include "level_zero/zes_api.h". That's a bit strange because "zes_api.h" does a "#include ze_api.h" instead of "#include level_zero/ze_api.h" but GCC manages to find level_zero/ze_api.h anyway.

If so, I don't know what to do with my PR. libze_loader.pc gives enough cflags to find "level_zero/ze_api.h", but the name "libze_loader.pc" doesn't look like the obvious name of the pkg-config to find ze headers.

bmyates commented 3 years ago

Yes, #include <level_zero/ze_api.h> is the recommended way. zes_api.h can do "#include ze_api.h" because they are in the same directory and compilers search current working directory for headers.

What changes do you think we should make to package config?

bgoglin commented 3 years ago

My level-zero.pc doesn't need the level-zero subdirectory in cflags anymore, so it would basically become an empty wrapper that includes libze_loader.pc We could remove level-zero.pc entirely then (ie revert my PR) but we'd need a clear documentation stating that "libze_loader.pc" is the recommended way to get level_zero cflags despite the strange name of the .pc file.

bgoglin commented 3 years ago

I'd like to know if you're going to change or remove my level-zero.pc, my L0-enabled release of hwloc is waiting for this.

bmyates commented 3 years ago

If you no longer need level-zero.pc and no one else is using it, then we can remove it.

Would you be able to open a PR with the documentation you are proposing?

bgoglin commented 3 years ago

I am not sure where to document these, but if you clarify the way to #include headers for issue #57, you may add a note there saying that libze_loader.pc is the pkg-config file to use for finding those headers. And I guess we could also improve the name and description in libze_loader.pc?