-
Notifications
You must be signed in to change notification settings - Fork 113
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
atomic instruction of global value considered active (should be inactive) #2212
Comments
After looking through the enzyme code, I figured that I could mark
I tried 1, but this didn't seem to have any effect (it could be an inkwell bug as I also tried to print the module and it segfaulted when it got to the metadata I added). I tried 2 and this worked and enzyme no longer errored on the atomicrmw instruction. I'll carry on and check that the forward gradient is calculated correctly |
in this case the two easiest thigns are
|
Thanks @wsmoses, marking thread_counter as inactive worked for me. I've moved onto reverse mode autodiff and have another problem related to atomics. I have a function that looks like this (in C for readability, but I write the llvm ir directly): int dostuff(float* arr, int arr_len, float* data, int i, int n) {
// data[0] is broadcast to arr[:]
int start_j = i * arr_len / n;
int end_j = (i + 1) * arr_len / n;
for(int j = start_i; j < end_i; j++) {
arr[j] = data[0];
}
// arr[0] += data[1]
if (i == 0) {
arr[0] += data[1];
}
} The idea is that I have When I do a reverse mode autodiff on this function with dup args I've seen there is an option on |
I'm using the
EnzymeCreateForwardDiff
function in enzyme to calculate the gradient of a function (rhs
). This function calculates the gradient of a vector-valued function. I'm using threading: the function is designed to be called from different threads, passing in two ints that give the current thread id, and the total number of threads. Each thread computes part of the vector of valuesI'm using atomics to implement synchronisation barriers within the function, and this is where my problem is occuring. I have a global value
thread_counter
which is used to implement the barrier, and enzyme is incorrectly considering this global as active, but it should have no effect on the values I'm taking the gradient of. Is there a way of forcing enzyme to considerthread_counter
as inactive?The IR for the function and the error I'm getting is reproduced below:
The text was updated successfully, but these errors were encountered: