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

Add Abstraction for OpenMP #979

Closed
RoyiAvital opened this issue Oct 3, 2020 · 5 comments
Closed

Add Abstraction for OpenMP #979

RoyiAvital opened this issue Oct 3, 2020 · 5 comments

Comments

@RoyiAvital
Copy link

Add dedicated option to enable or disable OpenMP.
For instance something like: open_mp("on") or open_mp("off") with "off" being the default.

It will automatically set the correct compilation flags (-fopenmp, /openmp, -qopenmp) and the linking.
Also it will be nice to be able to add advanced mode where the user points to the OpenMP library file (For instance, CLang can use Intel's OpenMP file which helps with compatibility in many cases [Example: MATLAB which uses Intel's OpenMP]).

@waruqi
Copy link
Member

waruqi commented Oct 4, 2020

I think it would be more suitable to support openmp by means of ʻadd_requires/add_packages/find_packages`.

for example:

Install openmp libraries and enable openmp flags.

add_requires("openmp", {configs = {...}}) 

target("test")
    set_kind("binary")
    add_files("src/*.c")
    add_packages("openmp")

Only find openmp libraries and enable openmp flags

target("test")
    set_kind("binary")
    add_files("src/*.c")
    on_load(function (target)
        target:add(find_packages("openmp"))
    end)

Some references:

@waruqi waruqi added this to the v2.3.8 milestone Oct 4, 2020
@RoyiAvital
Copy link
Author

As long as it has its own well documented section I think it is OK.
Just we need to take care of OpenMP as it is widely used.

Thanks.

@waruqi
Copy link
Member

waruqi commented Oct 4, 2020

Ok, I will arrange time to add it later, please wait some time.

@waruqi
Copy link
Member

waruqi commented Oct 12, 2020

I have supported it. see #990

for C

add_requires("libomp", {optional = true})
target("hello")
    set_kind("binary")
    add_files("src/*.c")
    add_rules("c.openmp")
    add_packages("libomp")

for C++

add_requires("libomp", {optional = true})
target("hello")
    set_kind("binary")
    add_files("src/*.cpp")
    add_rules("c++.openmp")
    add_packages("libomp")

@waruqi
Copy link
Member

waruqi commented Oct 12, 2020

@waruqi waruqi closed this as completed Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants