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

Building error in brnelib: "initializer expression refers to iteration variable 'i'" #1

Open
zyu494 opened this issue Oct 16, 2024 · 3 comments

Comments

@zyu494
Copy link

zyu494 commented Oct 16, 2024

Hi,

I'm encountering an error in the compute_costs function in the brne.cpp file located at /brne/brne_nav/brnelib/src/brne.cpp. The error is shown as follows:
error
I am using the following versions as listed in the dependency section: Armadillo: 12.6.6, Catch2: Version 3. I would appreciate any guidance or solution to resolve this issue. If there are any known fixes or workarounds, I'd love to hear about them.

Thanks in advance for your help!

@MuchenSun
Copy link
Collaborator

Hi!

This error is usually related to OpenMP, which version do you have?

Muchen

@zyu494
Copy link
Author

zyu494 commented Oct 17, 2024

Hi,
Thanks for your prompt response! Currently, I'm using gcc 9.4.0 and the version of OpenMP seems to be 5.0.

@zyu494 zyu494 closed this as completed Oct 17, 2024
@zyu494 zyu494 reopened this Oct 17, 2024
@MuchenSun
Copy link
Collaborator

The error is likely caused by how "j" is initialized in Line 132 (the initialization of "j", which is parallelized with OpenMP, should not depend on the initialization of "i", which is also parallelized with OpenMP). Could you please try the following change and let me know how it goes (starting with line 131)?

for (auto i=0; i<size; i++){
    for (auto j=0; j<size; j++){
        if (j < i) {continue;}
        ...
    }
}

If it doesn't work, you can also try to replace line 130 with "#pragma omp parallel for", in which case only the outer loop will be parallelized.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants