-
Notifications
You must be signed in to change notification settings - Fork 125
add UR loader, null adapter and basic example #93
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
Conversation
.github/workflows/cmake.yml
Outdated
run: cmake --build ${{github.workspace}}/build --target check-generated --config ${{env.BUILD_TYPE}} | ||
|
||
- name: Build | ||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me this --config param doesn't change anything. What is relevant here for setting up debug or release build is the -DCMAKE_BUILD_TYPE argument which you added in the previous step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe --config
is important when using the Visual Studio project generator. This will be defaulting to the Unix Makefiles generation though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a template :) I'll remove that config part. Windows is probably going to need its own separate job anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.gitignore
Outdated
@@ -53,6 +53,9 @@ | |||
# Debug files | |||
scripts/**/*.json | |||
|
|||
# Python cache | |||
scripts/templates/__pycache__/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dir can be generated in scripts/
, too. Maybe generalize this to sth like scripts/**/__pycache__/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
**General**: | ||
|
||
If you've made modifications to the specification, you can also run a custom `generate` target prior to building. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to move this section to be one of the first ones, so this will be something that the user will try using first instead of doing this the hard way (by figuring out which script should be run and with which params, see Source Code Generation section and the linked README).
Its going to take me a whole to review this and I have a busy day today, I'll get back to it tomorrow. |
No rush - I know it's a huge PR, but I think it's the bare minimum that makes sense. Thankfully most of it is automatically generated... |
} | ||
static const size_t DEVICE_NAME_MAX_LEN = 1024; | ||
char device_name[DEVICE_NAME_MAX_LEN] = {0}; | ||
status = urDeviceGetInfo(d, UR_DEVICE_INFO_NAME, DEVICE_NAME_MAX_LEN - 1, static_cast<void *>(&device_name), nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be extended by the check on the actual device name length returned from this function (with a last parameter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep the example short. Checking the length here doesn't add much - device_name will be a valid NULL-terminated C string, which cout
should output correctly.
In a test, on the other hand, we should verify that if this function returns success, the name is populated with a non-zero length string.
scripts/json2src.py
Outdated
if args.loader: | ||
generate_code.generate_loader(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) | ||
if args.layers: | ||
generate_code.generate_layers(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no generate_layers() in generate_code module. Safe to remove this call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to remove it entirely since we will be adding the layer functionality soon. I commented out these lines, so it's impossible to call this a non-existent method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/common/ur_singleton.h
Outdated
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this is probably supported by almost any compiler, I think it is still non-standard, so it might be better to favour a traditional #ifndef
guard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/common/ur_singleton.h
Outdated
|
||
////////////////////////////////////////////////////////////////////////// | ||
/// a abstract factory for creation of singleton objects | ||
template<typename _singleton_t, typename _key_t> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think prefixing types with _
is UB since they are reserved by the compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/common/ur_util.h
Outdated
*/ | ||
|
||
#if defined(__cplusplus) | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/common/ur_util.h
Outdated
env = getenv(name); | ||
#endif | ||
|
||
if( ( nullptr == env ) || ( 0 == strcmp( "0", env ) ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think ( 0 == strcmp( "0", env ) )
is neccesarry here since we do return ( 0 == strcmp( "1", env ) );
on the line below which will return false if env is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch :) Done
source/common/ur_singleton.h
Outdated
auto key = getKey( std::forward<Ts>( _params )... ); | ||
|
||
if(key == 0) // No zero keys allowed in map | ||
return static_cast<_singleton_t*>(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would be to always have {}
in any control flow statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my preference as well. But I refrained from making any stylistic changes (the coding style is all over the place :-)). I suggest we pick a single style and enforce it with clang-format (we were planning on doing that soon after this PR was merged).
I can do it with this PR, but a) it might conflict with the generated files, so it's not trivial addition, and b) it would probably affect the entire repo, not just the loader, so might clutter the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as we have an issue to track these changes linked here, I'd be happy for them to be addressed in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I'll add an issue about adding style checking to the build system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing them in a future issue works for me 👍
source/loader/ur_lib.h
Outdated
* @file ur_lib.h | ||
* | ||
*/ | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use #ifndef
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/loader/ur_loader.h
Outdated
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use #ifndef
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/loader/ur_object.h
Outdated
* @file ur_object.h | ||
* | ||
*/ | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use #ifndef
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/loader/windows/lib_init.cpp
Outdated
* | ||
*/ | ||
|
||
#include "../ur_lib.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to avoid relative file paths here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* | ||
*/ | ||
|
||
#include "../ur_loader.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the minor things which could be addressed later, I think this looks good.
0a22152
to
05280a9
Compare
In addition to the review commits, I needed to address the conflicting workflow change that verified the python module. So I added a test/python/basic.py test that runs in the new cmake workflow. Once #94 is merged, we can modify that test to instantiate the UR_DDI class, and it should just work. |
1159f4b
to
76173e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments I've made - LGTM.
40e896d
to
2b6e5c3
Compare
The components this patch implements are mostly derived from the ones implemented by level-zero. This patch otherwise makes only the minimal amount of changes required for loader: - adds new CI that builds the loader - updates cmake scripts to build and install the loader - adds generate and check-generated custom cmake targets - adds a tiny hello-world example to verify loader functionality Co-authored-by: Brandon Yates <brandon.yates@intel.com> Co-authored-by: Lisanna Dettwyler <lisanna.dettwyler@intel.com> Co-authored-by: Patryk Kaminski <patryk.kaminski@intel.com> Co-authored-by: Krzysztof Swiecicki <krzysztof.swiecicki@intel.com>
git diff | ||
exit 1 | ||
fi | ||
cd ../include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this check get lost in the move to doing this in CMake?
The components this patch implements are mostly derived from the ones implemented by level-zero.
This patch otherwise makes only the minimal amount of changes required for loader:
Co-authored-by: Brandon Yates brandon.yates@intel.com
Co-authored-by: Lisanna Dettwyler lisanna.dettwyler@intel.com
Co-authored-by: Patryk Kaminski patryk.kaminski@intel.com
Co-authored-by: Krzysztof Swiecicki krzysztof.swiecicki@intel.com