Does Makefile generated by CMake support make -jN?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Does Makefile generated by CMake support make -jN?

Chaos Zhang
Hi, all,

I was trying to compile my project using CMake, after CMake generated Makefile.
I used `/usr/bin/time -v make` to make the Makefile,  got the result: 'Percent of CPU this job got: 96%'.
Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of CPU used is  'Percent of CPU this job got: 648%'.
So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.

Thanks a lot,
Chao
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Raymond Wan-2
Hi Chao,


On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang <[hidden email]> wrote:
> I was trying to compile my project using CMake, after CMake generated
> Makefile.
> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
> 'Percent of CPU this job got: 96%'.
> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of
> CPU used is  'Percent of CPU this job got: 648%'.
> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is
> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.


I'm not sure what you are asking...

You ran make with -j 8 and you got a percentage greater than 96% ...
this implies that the Makefile does support -jN, doesn't it?  If you
got 96% both times, then I would say there's a problem.

Is what you're wondering why it is 648% and not 800%?  I think that
depends on the dependencies in your Makefile.  It's possible that some
of them depend on each other in such a way that 8 parallel threads is
not possible.

Also, I can't remember the value returned by /usr/bin/time -v, but I
guess 648% is the average and not maximum.  So, perhaps there are
parts within the Makefile that only one thread could be used and then
it gets averaged out?

Ray
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chaos Zhang
Thanks for your reply Raymond, by 'If you got 96% both times, then I would say there's a problem.', did you mean if make performed like this, it means this project can't use make -jN? BTW, does CMake support some options to turn on hardware acceleration?
Raymond Wan-2 wrote
Hi Chao,


On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang <[hidden email]> wrote:
> I was trying to compile my project using CMake, after CMake generated
> Makefile.
> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
> 'Percent of CPU this job got: 96%'.
> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of
> CPU used is  'Percent of CPU this job got: 648%'.
> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is
> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.


I'm not sure what you are asking...

You ran make with -j 8 and you got a percentage greater than 96% ...
this implies that the Makefile does support -jN, doesn't it?  If you
got 96% both times, then I would say there's a problem.

Is what you're wondering why it is 648% and not 800%?  I think that
depends on the dependencies in your Makefile.  It's possible that some
of them depend on each other in such a way that 8 parallel threads is
not possible.

Also, I can't remember the value returned by /usr/bin/time -v, but I
guess 648% is the average and not maximum.  So, perhaps there are
parts within the Makefile that only one thread could be used and then
it gets averaged out?

Ray
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

J Decker
In reply to this post by Chaos Zhang


On Tue, Jul 12, 2016 at 7:54 PM, Chaos Zhang <[hidden email]> wrote:
Hi, all,

I was trying to compile my project using CMake, after CMake generated
Makefile.
I used `/usr/bin/time -v make` to make the Makefile,  got the result:
'Percent of CPU this job got: 96%'.
Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of
CPU used is  'Percent of CPU this job got: 648%'.
So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is
I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.


All the sources, headers, etc come from the IO system, from the disk, probably you're running into the bottleneck of how long it takes to move the memory for the compiler to do work on?  did you profile IO ?
 
Thanks a lot,
Chao



--
View this message in context: http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Andrew Melo
In reply to this post by Chaos Zhang
On Tue, Jul 12, 2016 at 10:48 PM, Chaos Zhang <[hidden email]> wrote:
> Thanks for your reply Raymond, by 'If you got 96% both times, then I would
> say there's a problem.', did you mean if make performed like this, it means
> this project can't use make -jN?

If "make -j1" and "make -j8" ran in the same amount of time, there
would be a problem. Since "make -j1" uses 96% CPU and "make -j8" uses
690% CPU, it implies that the "-j" options make compilation time
scale, which is what you want.

> BTW, does CMake support some options to
> turn on hardware acceleration?

What do you mean by "hardware acceleration"?



>
> Raymond Wan-2 wrote
>> Hi Chao,
>>
>>
>> On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang &lt;
>
>> zcsd2012@
>
>> &gt; wrote:
>>> I was trying to compile my project using CMake, after CMake generated
>>> Makefile.
>>> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
>>> 'Percent of CPU this job got: 96%'.
>>> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result
>>> of
>>> CPU used is  'Percent of CPU this job got: 648%'.
>>> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU
>>> is
>>> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
>>
>>
>> I'm not sure what you are asking...
>>
>> You ran make with -j 8 and you got a percentage greater than 96% ...
>> this implies that the Makefile does support -jN, doesn't it?  If you
>> got 96% both times, then I would say there's a problem.
>>
>> Is what you're wondering why it is 648% and not 800%?  I think that
>> depends on the dependencies in your Makefile.  It's possible that some
>> of them depend on each other in such a way that 8 parallel threads is
>> not possible.
>>
>> Also, I can't remember the value returned by /usr/bin/time -v, but I
>> guess 648% is the average and not maximum.  So, perhaps there are
>> parts within the Makefile that only one thread could be used and then
>> it gets averaged out?
>>
>> Ray
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>
>
>
>
>
> --
> View this message in context: http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593951.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake



--
--
Andrew Melo
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chaos Zhang
In reply to this post by J Decker
Thanks for your  references Decker, the condition is it cost close to three times time after i use CMake than already exist makefile  to build project. And i found the CPU  didn't use effectively than exist make flow, so i wonder if CMake provide some options to use CPU more effectively.
Thanks,
Chao
J Decker wrote
On Tue, Jul 12, 2016 at 7:54 PM, Chaos Zhang <[hidden email]> wrote:

> Hi, all,
>
> I was trying to compile my project using CMake, after CMake generated
> Makefile.
> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
> 'Percent of CPU this job got: 96%'.
> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of
> CPU used is  'Percent of CPU this job got: 648%'.
> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is
> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
>
>
All the sources, headers, etc come from the IO system, from the disk,
probably you're running into the bottleneck of how long it takes to move
the memory for the compiler to do work on?  did you profile IO ?


> Thanks a lot,
> Chao
>
>
>
> --
> View this message in context:
> http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chaos Zhang
In reply to this post by Andrew Melo
Thanks for your analysis for me Andrew. I can't use "-j" options, i think the reason is the project i dealed with is not parallel. Thus when i use "make -jN", it couldn't work correctly every time. Obviously it caused by the Makefile generated by CMake, so i wonder if there are some CMake options to use CPU effectively. Because i found when i use already exist Makefile, just use "make", it used about 480% CPU. And when i use CMake generated Makefile, it just uesd about 96% CPU. The "hardware acceleration" i said means how to CPU more effectively in CMake.

Thanks again,
Chao
Andrew Melo wrote
On Tue, Jul 12, 2016 at 10:48 PM, Chaos Zhang <[hidden email]> wrote:
> Thanks for your reply Raymond, by 'If you got 96% both times, then I would
> say there's a problem.', did you mean if make performed like this, it means
> this project can't use make -jN?

If "make -j1" and "make -j8" ran in the same amount of time, there
would be a problem. Since "make -j1" uses 96% CPU and "make -j8" uses
690% CPU, it implies that the "-j" options make compilation time
scale, which is what you want.

> BTW, does CMake support some options to
> turn on hardware acceleration?

What do you mean by "hardware acceleration"?



>
> Raymond Wan-2 wrote
>> Hi Chao,
>>
>>
>> On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang <
>
>> zcsd2012@
>
>> > wrote:
>>> I was trying to compile my project using CMake, after CMake generated
>>> Makefile.
>>> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
>>> 'Percent of CPU this job got: 96%'.
>>> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result
>>> of
>>> CPU used is  'Percent of CPU this job got: 648%'.
>>> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU
>>> is
>>> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
>>
>>
>> I'm not sure what you are asking...
>>
>> You ran make with -j 8 and you got a percentage greater than 96% ...
>> this implies that the Makefile does support -jN, doesn't it?  If you
>> got 96% both times, then I would say there's a problem.
>>
>> Is what you're wondering why it is 648% and not 800%?  I think that
>> depends on the dependencies in your Makefile.  It's possible that some
>> of them depend on each other in such a way that 8 parallel threads is
>> not possible.
>>
>> Also, I can't remember the value returned by /usr/bin/time -v, but I
>> guess 648% is the average and not maximum.  So, perhaps there are
>> parts within the Makefile that only one thread could be used and then
>> it gets averaged out?
>>
>> Ray
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>
>
>
>
>
> --
> View this message in context: http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593951.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake



--
--
Andrew Melo
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chuck Atkins
Thanks for your analysis for me Andrew. I can't use "-j" options, i think the
reason is the project i dealed with is not parallel. Thus when i use "make
-jN", it couldn't work correctly every time. Obviously it caused by the
Makefile generated by CMake, so i wonder if there are some CMake options to
use CPU effectively.

This usually means missing dependencies the CMakeLists.txt files.  Because of this you get unpredictable results when compiling in parallel.  Check your dependencies on targets, link lines, and source files and make sure they are all correct and not missing anything.

 
Because i found when i use already exist Makefile, just
use "make", it used about 480% CPU.

The Makefile is probably explicitly adding a fixed number of -j options.  CMake will not do this and instead rely on the user to call make with their desired appropriate level of parallelism.

 
And when i use CMake generated Makefile, it just uesd about 96% CPU. The "hardware acceleration" i said means how to
CPU more effectively in CMake.

-jN is as good as it gets for make.  That being said, you can always try a different generator, like Ninja, which tends to have quite a bit better build times in parallel.

First things first though, you need to get your dependency problem squared away.  That's the underlying cause of why your parallel builds with -j are unpredictable.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chaos Zhang
Hi, Chuck,

Thanks for your generous help.

Actually there is no make -j option in the already exist make flow of my project as i  know so far. Because i have read the makefiles in detail, and when i make my project, the sub projects in my project executed in order.

The problem i found is it cost much more time when use CMake generated Makefile to compile a single source file with gcc. I choose a passage of gcc options for each flow:

In alredy exist Makfile:

g++ “some gcc options like -W...”
-c -g -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 ... header_include_dir1header_include_dir2 ... -MMD -MP -MF -o src.o src.cpp

In CMake generated Makfile:

g++ “some gcc options like -W...”
-g header_include_dir1header_include_dir2 ... -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 -o src.o -c src.cpp

other files when compile are also like above, but will cost much more time(2-3times), could you please give me some advices? If you need more details, please email me.

Sincere thanks,
Chao

Chuck Atkins wrote
>
> Thanks for your analysis for me Andrew. I can't use "-j" options, i think
> the

reason is the project i dealed with is not parallel. Thus when i use "make
> -jN", it couldn't work correctly every time. Obviously it caused by the
> Makefile generated by CMake, so i wonder if there are some CMake options to
> use CPU effectively.


This usually means missing dependencies the CMakeLists.txt files.  Because
of this you get unpredictable results when compiling in parallel.  Check
your dependencies on targets, link lines, and source files and make sure
they are all correct and not missing anything.



> Because i found when i use already exist Makefile, just
> use "make", it used about 480% CPU.


The Makefile is probably explicitly adding a fixed number of -j options.
CMake will not do this and instead rely on the user to call make with their
desired appropriate level of parallelism.



> And when i use CMake generated Makefile, it just uesd about 96% CPU. The
> "hardware acceleration" i said means how to
> CPU more effectively in CMake.
>

-jN is as good as it gets for make.  That being said, you can always try a
different generator, like Ninja, which tends to have quite a bit better
build times in parallel.

First things first though, you need to get your dependency problem squared
away.  That's the underlying cause of why your parallel builds with -j are
unpredictable.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Gonzalo Garramuño
In reply to this post by Chaos Zhang


El 13/07/16 a las 03:21, Chaos Zhang escribió:
> Thanks for your  references Decker, the condition is it cost close to three
> times time after i use CMake than already exist makefile  to build project.
> And i found the CPU  didn't use effectively than exist make flow, so i
> wonder if CMake provide some options to use CPU more effectively.
> Thanks,
> Chao
If you are looking to speed up compilation times, you should switch from
Makefiles to Ninja build files (-G Ninja).  It has a much faster
detection of dependencies and compiles overall much faster.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Does Makefile generated by CMake support make -jN?

Chaos Zhang
In reply to this post by Chaos Zhang
Hi, Raymond, J Decker, Andrew, Chuck,

Thanks a lot for your generous help, i have found it was dependencies missing of my project, for i have not found my project was built in parallel.

BTW, i have used env var "MAKEFLAGS=-j" to make in parallel, is there any way i can set "make -j" option in CMake file? For i use Qt Creator as IDE, and the CMake compile system is provided for other R&D teams, so i want to make the CMake compile system as simply and automatically as i can. Could you please give me some advice?

Thanks again,
Chao
Chaos Zhang wrote
Hi, Chuck,

Thanks for your generous help.

Actually there is no make -j option in the already exist make flow of my project as i  know so far. Because i have read the makefiles in detail, and when i make my project, the sub projects in my project executed in order.

The problem i found is it cost much more time when use CMake generated Makefile to compile a single source file with gcc. I choose a passage of gcc options for each flow:

In alredy exist Makfile:

g++ “some gcc options like -W...”
-c -g -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 ... header_include_dir1header_include_dir2 ... -MMD -MP -MF -o src.o src.cpp

In CMake generated Makfile:

g++ “some gcc options like -W...”
-g header_include_dir1header_include_dir2 ... -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 -o src.o -c src.cpp

other files when compile are also like above, but will cost much more time(2-3times), could you please give me some advices? If you need more details, please email me.

Sincere thanks,
Chao

Chuck Atkins wrote
>
> Thanks for your analysis for me Andrew. I can't use "-j" options, i think
> the

reason is the project i dealed with is not parallel. Thus when i use "make
> -jN", it couldn't work correctly every time. Obviously it caused by the
> Makefile generated by CMake, so i wonder if there are some CMake options to
> use CPU effectively.


This usually means missing dependencies the CMakeLists.txt files.  Because
of this you get unpredictable results when compiling in parallel.  Check
your dependencies on targets, link lines, and source files and make sure
they are all correct and not missing anything.



> Because i found when i use already exist Makefile, just
> use "make", it used about 480% CPU.


The Makefile is probably explicitly adding a fixed number of -j options.
CMake will not do this and instead rely on the user to call make with their
desired appropriate level of parallelism.



> And when i use CMake generated Makefile, it just uesd about 96% CPU. The
> "hardware acceleration" i said means how to
> CPU more effectively in CMake.
>

-jN is as good as it gets for make.  That being said, you can always try a
different generator, like Ninja, which tends to have quite a bit better
build times in parallel.

First things first though, you need to get your dependency problem squared
away.  That's the underlying cause of why your parallel builds with -j are
unpredictable.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake