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

removed locks which cause unneccesary wait #24

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added LU_factorisation
Binary file not shown.
8 changes: 0 additions & 8 deletions src/LU_factorisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ using namespace std;
// LU Decomposition function
void l_u_d(float** a, float** l, float** u, int size)
{
// Initialize a simple lock for parallel region
omp_lock_t lock;
omp_init_lock(&lock);

// Initialize L and U matrices
for (int i = 0; i < size; i++) {
Expand All @@ -35,29 +32,24 @@ void l_u_d(float** a, float** l, float** u, int size)
// Update U matrix
#pragma omp for schedule(static)
for (int j = k; j < size; j++) {
omp_set_lock(&lock);
u[k][j] = a[k][j];
for (int s = 0; s < k; s++) {
u[k][j] -= l[k][s] * u[s][j];
}
omp_unset_lock(&lock);
}

// Update L matrix
#pragma omp for schedule(static)
for (int i = k + 1; i < size; i++) {
omp_set_lock(&lock);
l[i][k] = a[i][k];
for (int s = 0; s < k; s++) {
l[i][k] -= l[i][s] * u[s][k];
}
l[i][k] /= u[k][k];
omp_unset_lock(&lock);
}
}
}

omp_destroy_lock(&lock);
}
int main(int argc, char *argv[]) {
int size = 2;
Expand Down