Skip to content

Commit 821a606

Browse files
committed
Merge branch 'nsct' of github.com:Devsh-Graphics-Programming/Nabla into nsct
2 parents f11ade6 + 49548ad commit 821a606

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,25 @@ if(NOT CMAKE_BUILD_TYPE)
108108
endif()
109109

110110
option(_NBL_MEMORY_CONSUMPTION_CHECK_SKIP_ "Turn it ON to bypass memory consumption test given _NBL_JOBS_AMOUNT_. Be aware you are doing it on your own risk of potential build failures!" OFF)
111+
option(_NBL_JOBS_OVERRIDE_ "Override jobs with safe bias if required to respect currently available memory" OFF)
111112

112113
include(ProcessorCount)
114+
113115
if(NOT DEFINED _NBL_JOBS_AMOUNT_)
114-
ProcessorCount(_NBL_JOBS_AMOUNT_)
115-
if(_NBL_JOBS_AMOUNT_ EQUAL 0)
116-
set(_NBL_JOBS_AMOUNT_ 1)
116+
if(NOT "$ENV{_NBL_JOBS_AMOUNT_}" STREQUAL "")
117+
set(_NBL_JOBS_AMOUNT_ "$ENV{_NBL_JOBS_AMOUNT_}")
118+
else()
119+
ProcessorCount(_NBL_JOBS_AMOUNT_)
120+
if(_NBL_JOBS_AMOUNT_ EQUAL 0)
121+
set(_NBL_JOBS_AMOUNT_ 1)
122+
endif()
117123
endif()
118124
endif()
119125

120126
cmake_host_system_information(RESULT _NBL_TOTAL_PHYSICAL_MEMORY_ QUERY TOTAL_PHYSICAL_MEMORY) # MB
121127
cmake_host_system_information(RESULT _NBL_AVAILABLE_PHYSICAL_MEMORY_ QUERY AVAILABLE_PHYSICAL_MEMORY) # MB
122128

123-
if(NBL_CI_MODE)
129+
if(_NBL_JOBS_OVERRIDE_)
124130
math(EXPR _CI_NBL_JOBS_AMOUNT_ "(${_NBL_AVAILABLE_PHYSICAL_MEMORY_} - 512)/(2*1024)") # override with safe bias, respect memory and don't take more then max processors we have
125131
if(_CI_NBL_JOBS_AMOUNT_ LESS _NBL_JOBS_AMOUNT_)
126132
message(WARNING "Overriding _NBL_JOBS_AMOUNT_: \"${_NBL_JOBS_AMOUNT_}\" with \"${_CI_NBL_JOBS_AMOUNT_}\"")
@@ -129,7 +135,7 @@ if(NBL_CI_MODE)
129135
endif()
130136
endif()
131137

132-
set(_NBL_JOBS_AMOUNT_ "${_NBL_JOBS_AMOUNT_}" CACHE STRING "Max jobs amount for the build to be invoked" FORCE)
138+
message(STATUS "_NBL_JOBS_AMOUNT_: \"${_NBL_JOBS_AMOUNT_}\"")
133139

134140
math(EXPR _NBL_DEBUG_MEMORY_CONSUPTION_WITH_ALL_JOBS_ "${_NBL_JOBS_AMOUNT_}*2*1024") # MB
135141
math(EXPR _NBL_CURRENTLY_USED_PHYSICAL_MEMORY_ "${_NBL_TOTAL_PHYSICAL_MEMORY_}-${_NBL_AVAILABLE_PHYSICAL_MEMORY_}") # MB

0 commit comments

Comments
 (0)