-
Notifications
You must be signed in to change notification settings - Fork 40
Add resident device change call #1517
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
base: main
Are you sure you want to change the base?
Conversation
d53a23f
to
9d7e12c
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.
14 / 16 files reviewed (will be continued)
…OINTER_TESTING_PROPS
@lukaszstolarczuk , @bratpiorka , @ldorau , @lplewa , please do the same wrt your comments when you're back |
|
||
uint32_t existing_peer_index = 0; | ||
utils_write_lock(&ze_provider->resident_device_rwlock); | ||
while (existing_peer_index < ze_provider->resident_device_count && |
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.
you do the incrementation within the while loop and have extra &&
to mark the stop, I believe I agree with Łukasz - this would look better as for
.
// you obviously don't have to init anything in for (e.g. for(; index < count; index++)
test/common/CMakeLists.txt
Outdated
add_umf_library( | ||
NAME umf_ze_loopback | ||
TYPE SHARED | ||
SRCS ze_loopback.h ze_loopback.cpp |
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.
.h is not needed?
test/common/level_zero_mocks.cpp
Outdated
|
||
#include "umf/providers/provider_level_zero.h" | ||
#include "utils_load_library.h" | ||
#include <cstdlib> |
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.
#include <cstdlib>
#include <umf/providers/provider_level_zero.h>
#include "level_zero_mocks.h"
#include "utils_load_library.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.
ok, applied
test/common/level_zero_mocks.h
Outdated
#ifndef UMF_TEST_PROVIDER_LEVEL_ZERO_MOCKS_H | ||
#define UMF_TEST_PROVIDER_LEVEL_ZERO_MOCKS_H | ||
|
||
#include "utils_log.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.
#include <vector>
#include <gmock/gmock.h>
#include "utils_log.h"
#include "ze_loopback.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.
ok, applied
test/common/ze_loopback.cpp
Outdated
* | ||
*/ | ||
|
||
#include "ze_loopback.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.
#include <cstdlib>
#include <iostream>
#include "ze_loopback.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.
ok, applied
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "../common/level_zero_mocks.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.
#include <umf/pools/pool_disjoint.h>
#include <umf/providers/provider_level_zero.h>
#include "gtest/gtest.h"
#include "../common/level_zero_mocks.h"
#include "pool.hpp"
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.
ok, applied
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.
Please refactor commits structure.
commits in PR should be split to functional parts, with proper commit message.
Each commit should work (at least it should build - but we do not check it so exception happens). You should not split implementation, tests, documentation to separate commits.
If i were you i would create(This list is an inspiration for proper commits structure, you do not have split your PR to exactly this commits) : commit for adding iterate over critnib, commit for changes in asserts, maybe commit for this mock library, commit for allowing ovveride lib_name, commit for change in setResidentDevides, commit for main functionality of this PR....
void critnib_iter(critnib *c, uintptr_t min, uintptr_t max, | ||
int (*func)(uintptr_t key, void *value, void *privdata), | ||
void *privdata) { | ||
bool wasIterating = false; |
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.
move lock inside if - then you can just add else to if instead extra variable. This will make it a lite bit easier to read.
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.
no, because I want to access root in if (c->root)
under the lock too
|
||
uint32_t existing_peer_index = 0; | ||
utils_write_lock(&ze_provider->resident_device_rwlock); | ||
while (existing_peer_index < ze_provider->resident_device_count && |
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.
Yes i noticed that you need it outside of loop - this is why i write
for(index = 0; index < count; index++) if (device[index] == index) break;
not
for (int index = 0; index < count; index++) if (device[index] == index) break;
If something is for loop we should use for not while. If you need access to loop counter outside of function you can declare it before loop - this is a standard approach which should not confuse reader.
LOG_ERR("umfMemoryTrackerIterateAll did not manage to do some change " | ||
"numFailed: %d, numSuccess: %d", | ||
privData.success_changes, privData.failed_changes); | ||
return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; |
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.
When returining this error code get_last_native_error function should be able to return more precise error message - please add support for it.
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.
ok, added store_last_native_error(result);
in ze_memory_provider_resident_device_change_helper
.failed_changes = 0, | ||
}; | ||
|
||
umf_result_t result = umfMemoryTrackerIterateAll( |
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 miss communicated - I will follow up on this later on.
return 0; | ||
} | ||
|
||
umf_result_t umfLevelZeroMemoryProviderResidentDeviceChange( |
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 would prefer to have add and remove function - i recall pbalcer already suggested it too.
I will split it to 3 functions - add, delete, and helper function to iterate over existing allocations (so we limit code duplication)
Refactor will be squashing all commits to one during merge. |
We do not do squash merge in this project |
UMF part of https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_oneapi_peer_access.asciidoc feature.
UR/llvm part is in intel/llvm#19257