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

Tidy and move common adapter code to ur_common #997

Closed

Conversation

callumfare
Copy link
Contributor

@callumfare callumfare commented Oct 25, 2023

  • Move common code from ur.cpp and ur.hpp to the ur_common static library.
  • Tidy up this shared code at the same time - mostly formatting to match the adapter code, and putting helper classes in namespaces to clarify that they aren't part of UR itself but just implementation details.
  • Fix missing includes in the adapters as a result of moving from ur.hpp to ur_util.hpp
  • Also fix unused definition of GetHipFormatPixelSize on HIP < 5.6 as this came up when I was testing locally

@callumfare callumfare force-pushed the callum/adapter_util_lib branch from 2750320 to 159963b Compare October 25, 2023 15:59
@pbalcer
Copy link
Contributor

pbalcer commented Oct 26, 2023

adapters already link with common. Any reason this new stuff can't be part of that library? there's already an ur_util.hpp file.

@kbenzie
Copy link
Contributor

kbenzie commented Oct 26, 2023

adapters already link with common. Any reason this new stuff can't be part of that library? there's already an ur_util.hpp file.

That might make more sense, yeah.

@callumfare callumfare force-pushed the callum/adapter_util_lib branch 2 times, most recently from 698f581 to ac29419 Compare October 26, 2023 11:57
@callumfare
Copy link
Contributor Author

adapters already link with common. Any reason this new stuff can't be part of that library? there's already an ur_util.hpp file.

I'm waiting for the CI to rerun on the latest commit, but after moving this into common the quick fuzztest job was failing because of ODR violations. I think because common is an interface library the definitions in ur_adapter_util.cpp are being pulled in multiple times. Either I can revert and keep the adapter utils as a separate static library, or possibly just remove the entire cpp file and make it header-only. PrintTrace and the platform cache are only used by the Level Zero adapter now anyway so could be moved there.

@kbenzie
Copy link
Contributor

kbenzie commented Oct 26, 2023

I think because common is an interface library the definitions in ur_adapter_util.cpp are being pulled in multiple times.

Sounds like it should be a static library instead.

@kbenzie
Copy link
Contributor

kbenzie commented Oct 26, 2023

In fact, it already is on the main branch https://github.com/oneapi-src/unified-runtime/blob/main/source/common/CMakeLists.txt#L9

@fabiomestre fabiomestre changed the base branch from adapters to main December 5, 2023 16:52
@fabiomestre
Copy link
Contributor

I have updated the target branch of this PR from the adapters branch to the main branch.
Development in UR is moving back to main. The adapters branch will soon be deleted.

Copy link
Contributor

@pbalcer pbalcer left a comment

Choose a reason for hiding this comment

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

please rebase.

@callumfare callumfare force-pushed the callum/adapter_util_lib branch 7 times, most recently from 471c118 to 4f70a6b Compare December 12, 2023 16:31
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 76 lines in your changes are missing coverage. Please review.

Comparison is base (8007b22) 15.59% compared to head (800bf88) 15.57%.
Report is 2 commits behind head on main.

Files Patch % Lines
source/common/ur_util.hpp 0.00% 58 Missing ⚠️
...ource/loader/layers/sanitizer/asan_interceptor.cpp 0.00% 13 Missing ⚠️
...ource/loader/layers/sanitizer/asan_interceptor.hpp 0.00% 4 Missing ⚠️
source/common/ur_util.cpp 92.85% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #997      +/-   ##
==========================================
- Coverage   15.59%   15.57%   -0.02%     
==========================================
  Files         232      231       -1     
  Lines       32089    32087       -2     
  Branches     3638     3638              
==========================================
- Hits         5003     4999       -4     
- Misses      27036    27037       +1     
- Partials       50       51       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@callumfare callumfare force-pushed the callum/adapter_util_lib branch from 4f70a6b to 482eec0 Compare December 12, 2023 16:52
@callumfare callumfare changed the title Tidy and move common code to separate adapter_util static library Tidy and move common adapter code to ur_common Dec 13, 2023
@callumfare
Copy link
Contributor Author

I've rebased now. Note that I had to add /D_CRT_SECURE_NO_WARNINGS to ur_common on Windows, which was previously needed in the L0 adapter. I also had to add /DNOMINMAX to the L0 adapter as a result of includes moving around.

@callumfare callumfare marked this pull request as ready for review December 13, 2023 08:55
@callumfare callumfare requested review from a team as code owners December 13, 2023 08:55
@callumfare callumfare requested a review from a team as a code owner December 13, 2023 08:55
Copy link
Contributor

@PietroGhg PietroGhg left a comment

Choose a reason for hiding this comment

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

native cpu LGTM, thank you

@callumfare callumfare force-pushed the callum/adapter_util_lib branch 3 times, most recently from 8e9b6d0 to 3424ed7 Compare December 13, 2023 12:11
Copy link
Contributor

@isaacault isaacault left a comment

Choose a reason for hiding this comment

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

source/adapters/*/image.cpp changes LGTM.

Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

command-buffer changes LGTM

@callumfare callumfare force-pushed the callum/adapter_util_lib branch 2 times, most recently from c0b5155 to d867d48 Compare January 9, 2024 12:54
@callumfare
Copy link
Contributor Author

@oneapi-src/unified-runtime-cuda-write @oneapi-src/unified-runtime-hip-write @oneapi-src/unified-runtime-level-zero-write Please review when you get a chance

Copy link
Contributor

@GeorgeWeb GeorgeWeb left a comment

Choose a reason for hiding this comment

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

CUDA and HIP changes after refactor look good to me.

@@ -10,7 +10,7 @@
#pragma once

#include <cuda.h>
#include <ur/ur.hpp>
#include <ur_api.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a distinction between the #include <ur_api.h> (h-char-sequence) and #include "ur_api.h" (q-char-sequence). Though the c99 standard (and by reference c++11 - c++20) leave latitude for interpretation of these two forms, it's standard practise to use the "q" form for internal includes and the "h" form for system includes (see e.g. llvm).

Since ur_api.h is part of the present project, I believe all instances should the quoted form. Such a general cleanup certainly belongs in a separate patch, but for all changes introduced changes here, I think it makes sense to use q-char uniformly

@@ -9,7 +9,8 @@
//===----------------------------------------------------------------------===//
#pragma once

#include <ur/ur.hpp>
#include <memory>
#include <ur_api.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the headers not ordered hierarchically e.g local, 3rd-party, standard-library or similar?

@@ -15,6 +15,7 @@

namespace {

#if HIP_VERSION >= 50600000
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this belong in a separate patch?

Copy link
Contributor

@nrspruit nrspruit left a comment

Choose a reason for hiding this comment

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

LGTM for level zero

@callumfare callumfare force-pushed the callum/adapter_util_lib branch from d867d48 to 800bf88 Compare January 17, 2024 14:05
@kbenzie kbenzie added loader Loader related feature/bug common Changes or additions to common utilities level-zero L0 adapter specific issues cuda CUDA adapter specific issues hip HIP adapter specific issues opencl OpenCL adapter specific issues native-cpu Native CPU adapter specific issues labels Apr 10, 2024
@martygrant
Copy link
Contributor

Unified Runtime -> intel/llvm Repo Move Notice

Information

The source code of Unified Runtime has been moved to intel/llvm under the unified-runtime top-level directory,
all future development will now be carried out there. This was done in intel/llvm#17043.

The code will be mirrored to oneapi-src/unified-runtime and the specification will continue to be hosted at oneapi-src.github.io/unified-runtime.

The contribution guide has been updated with new instructions for contributing to Unified Runtime.

PR Migration

All open PRs including this one will be labelled auto-close and shall be automatically closed after 30 days.
To allow for some breathing space, this automation will not be enabled until next week (27/02/2025).

Should you wish to continue with your PR you will need to migrate it to intel/llvm.
We have provided a script to help automate this process.


This is an automated comment.

@martygrant
Copy link
Contributor

Unified Runtime -> intel/llvm Repo Move Notice

Following on from the previous notice, we have now enabled workflows to automatically label and close PRs because the Unified Runtime source code has moved to intel/llvm.

This PR has now been marked with the auto-close label and will be automatically closed after 30 days.

Please review the previous notice for more information, including assistance with migrating your PR to intel/llvm.

Should there be a reason for this PR to remain open, manually remove the auto-close label.


This is an automated comment.

Copy link

Automatic PR Closure Notice

Information

This PR has been closed automatically. It was marked with the auto-close label 30 days ago as part of the Unified Runtime source code migration to the intel/llvm repository - intel/llvm#17043.

All Unified Runtime development should be done in intel/llvm, details can be found in the updated contribution guide.
This repository will continue to exist as a mirror and will host the specification documentation.

Next Steps

Should you wish to re-open this PR it must be moved to intel/llvm. We have provided a script to help automate this process, otherwise no actions are required.


This is an automated comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-close common Changes or additions to common utilities cuda CUDA adapter specific issues hip HIP adapter specific issues level-zero L0 adapter specific issues loader Loader related feature/bug native-cpu Native CPU adapter specific issues opencl OpenCL adapter specific issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.