]> Creatis software - clitk.git/commitdiff
revived old fast_make script / clean some dependencies
authorschaerer <schaerer>
Tue, 5 Oct 2010 18:00:15 +0000 (18:00 +0000)
committerschaerer <schaerer>
Tue, 5 Oct 2010 18:00:15 +0000 (18:00 +0000)
common/clitkFilterBase.cxx
common/clitkFilterBase.h
common/clitkImageCommon.cxx
common/clitkImageCommon.h
common/clitkImageToImageGenericFilterBase.h
common/clitkLabelizeParameters.h
common/clitkTimer.h
fast_make.sh

index 0f7e85250340819448094c119239bff56918e771..09797d886c750959c84dfa4e6a4db0eb236563e4 100644 (file)
@@ -18,6 +18,7 @@
 
 // clitk
 #include "clitkFilterBase.h"
+#include "clitkCommon.h"
 
 //--------------------------------------------------------------------
 clitk::FilterBase::FilterBase() 
index 1cd75794d6aa2bdc190c4d6bca4c755979cdd6a9..a53f655d527a5bdcea53e6d955eb2ed0490d39da 100644 (file)
@@ -20,7 +20,7 @@
 #define CLITKFILTERBASE_H
 
 // clitk
-#include "clitkCommon.h"
+//#include "clitkCommon.h"
 #include "clitkTimer.h"
 #include "clitkFilterMacros.txx"
 #include "clitkLabelizeParameters.h"
index 9367257f9c7a03e38a7174314a8c76e834fd41cc..cfcbbe34225b3034adab9770bf127e92bfeb1f69 100644 (file)
@@ -20,6 +20,7 @@
 #define CLITKIMAGECOMMON_CXX
 
 #include "clitkImageCommon.h"
+#include "clitkCommon.h"
 
 //--------------------------------------------------------------------
 void clitk::ReadImageDimensionAndPixelType(const std::string & filename,
index 9744fc962cc666a4c156f90e56be41628c7191ec..9e61223e0ab77484ed6566f1c0f91c2bea4fb0b7 100644 (file)
@@ -19,7 +19,7 @@
 #define CLITKIMAGECOMMON_H
 
 // clitk
-#include "clitkCommon.h"
+//#include "clitkCommon.h"
 
 // itk
 #include "itkImage.h"
index 86cd77a7d1adfd0310535811c3cf30f8653070a5..280dd6569a4ce25c622339c25a3a5f85fcff1b08 100644 (file)
@@ -20,7 +20,6 @@
 #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H
 
 // clitk 
-#include "clitkCommon.h"
 #include "clitkImageCommon.h"
 #include "clitkCommonGenericFilter.h"
 #include "clitkFilterBase.h"
index 7a4ced985328e3c1259227a387ff3e694d5fa9ac..8f7c1264478ce1e72101a601e5e32a202c040ec2 100644 (file)
@@ -20,7 +20,7 @@
 #define CLITKLABELIZEPARAMETERS_H
 
 // clitk
-#include "clitkCommon.h"
+//#include "clitkCommon.h"
 
 // itk
 #include "itkObject.h"
index 2134f41ba865390e3921ff06b1d3133cf84a478b..dcc32be755a6260eb295ee151c60894e9e200033 100644 (file)
@@ -27,7 +27,7 @@
 
    ===================================================================*/
 
-#include "clitkCommon.h"
+//#include "clitkCommon.h"
 #include <ctime> 
 #if defined(unix) || defined(__APPLE__)
 #  include <sys/time.h>
index 0ee2e4fa360a2dc857998abbd70c8158bfdd733a..7a11e0a62a2b022115501c936def0e8e94597fa4 100755 (executable)
@@ -7,15 +7,28 @@ cd ${vv_dir}/build
 function handle_exit
 {
     rm mem_use 2>>/dev/null
-    killall -s SIGCONT make
-    killall make
-    killall cc1plus
+    #kill -s SIGCONT ${make_pid} $(get_descendance ${make_pid})
+    #sleep 1
+    kill -9 $(get_descendance ${make_pid})
+    kill -9 ${make_pid}
     echo "Terminated, exiting..."
+    sleep 1
     echo
     echo
     exit
 }
 
+function get_descendance
+{
+    children=$(ps --ppid $1 -o pid --no-headers)
+    local desc=""
+    for c in $children
+    do
+        desc="${desc} ${c} $(get_descendance $c)"
+    done
+    echo $desc
+}
+
 trap handle_exit SIGINT
 available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*)
 if [ -a "memory_exhausted_lock" ]
@@ -37,37 +50,44 @@ make_pid=$(jobs -p %nice)
 #watch memory use to avoid crashes
 while ps $make_pid >>/dev/null 
 do
-    if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ]
+    descendance=$(get_descendance ${make_pid})
+    #echo ${make_pid} $descendance
+    ps -o vsize --no-headers ${make_pid} ${descendance} > mem_use
+    used_mem=$(awk 'BEGIN {sum=0;} {sum+=$1;} END {print sum;}' mem_use)
+    if (( "$used_mem"> ($available_mem - 300) ))
     then
-        ps ax -o vsize,comm | grep cc1plus | grep -o "\<[0-9]*\>" > mem_use
-        used_mem=$(awk 'BEGIN {sum=0;} {sum+=$1;} END {print sum;}' mem_use)
-        if (( "$used_mem"> ($available_mem - 300) ))
-        then
-            touch memory_exhausted_lock
-            echo "Stopping due to exagerated memory use ( $used_mem )"
-            handle_exit
-        elif (( "$used_mem"> ($available_mem/2) ))
-        then
-            if [ x$high_mem != xtrue ]
-            then
-                echo "Warning, high memory use, not spawning any more compilation jobs... ( $used_mem )"
-                killall -s SIGSTOP make
-                killall -s SIGCONT cc1plus
-                high_mem="true"
-                date_mem=$(date +%s)
-            fi
-            echo mem $used_mem / $available_mem
-        elif [ x$high_mem = xtrue ] && (( $(date +%s) > ( $date_mem + 5 ) ))
+        touch memory_exhausted_lock
+        echo "Stopping due to exagerated memory use ( $used_mem )"
+        handle_exit
+    elif (( "$used_mem"> ($available_mem/2) ))
+    then
+        if [ x$high_mem != xtrue ]
         then
-            echo "Memory use back to normal"
-            high_mem=""
-            killall -s SIGCONT make
+            echo "Warning, high memory use, not spawning any more compilation jobs... ( $used_mem )"
+            #Stop all make commands
+            for pid in ${make_pid} ${descendance}
+            do
+                (ps --no-headers -o command ${pid} | grep make &>/dev/null) && kill -s SIGSTOP ${pid}
+            done
+            high_mem="true"
+            date_mem=$(date +%s)
         fi
-        rm mem_use
+        echo mem $used_mem / $available_mem
+    elif [ x$high_mem = xtrue ] && (( $(date +%s) > ( $date_mem + 5 ) ))
+    then
+        echo "Memory use back to normal"
+        high_mem=""
+        #Restart all make commands
+        for pid in ${make_pid} ${descendance}
+        do
+            (ps --no-headers -o command ${pid} | grep make &>/dev/null) && kill -s SIGCONT ${pid}
+        done
     fi
+    rm mem_use
     sleep 1
 done
 rm memory_exhausted_lock 2>>/dev/null
+echo Waiting for remaining jobs...
 wait
 echo Done!
 echo