From e8da2d947a7096b7010643de1359e0462b7d0d15 Mon Sep 17 00:00:00 2001 From: Russell Grew <42530666+RussellGrew@users.noreply.github.com> Date: Fri, 5 Feb 2021 08:58:36 +1100 Subject: [PATCH 1/3] Bash script edits to make stackSentinel.py faster in places (#225) * plumb in num-process for time consuming steps * refine num-process speed enhancements * refine num-process speed enhancements * dedicated function for writing batch processes * refine num-process speed enhancements * fix indents Co-authored-by: Russell Grew --- contrib/stack/topsStack/Stack.py | 131 ++++++++++++++++++----- contrib/stack/topsStack/stackSentinel.py | 2 +- 2 files changed, 107 insertions(+), 26 deletions(-) diff --git a/contrib/stack/topsStack/Stack.py b/contrib/stack/topsStack/Stack.py index fbbd604..1f421fa 100644 --- a/contrib/stack/topsStack/Stack.py +++ b/contrib/stack/topsStack/Stack.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + #!/usr/bin/env python3 ######################## #Author: Heresh Fattahi @@ -13,6 +13,7 @@ defoMax = '2' maxNodes = 72 + class config(object): """ A class representing the config file @@ -242,6 +243,7 @@ class config(object): self.f.write('defomax : ' + self.defoMax + '\n') self.f.write('rlks : ' + self.rangeLooks + '\n') self.f.write('alks : ' + self.azimuthLooks + '\n') + self.f.write('numProcess : ' + self.numProcess + '\n') def denseOffset(self, function): self.f.write('###################################'+'\n') @@ -258,6 +260,18 @@ class config(object): #self.f.write('ww : 256\n') #self.f.write('wh : 128\n') + def write_wrapper_config2run_file(self, configName, line_cnt, numProcess = 1): + # dispassionate list of commands for single process + if numProcess == 1: + self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n') + # aggregate background commands between wait blocks for speed gains + elif numProcess > 1: + self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + ' &\n') + if line_cnt == numProcess: + self.runf.write('wait\n\n') + line_cnt = 0 + return line_cnt + def finalize(self): self.f.close() @@ -286,6 +300,7 @@ class run(object): swath_path = self.work_dir os.makedirs(self.config_path, exist_ok=True) + line_cnt = 0 for slcdate in acquisitionDates: configName = os.path.join(self.config_path,'config_unpack_'+slcdate) configObj = config(configName) @@ -300,8 +315,10 @@ class run(object): configObj.Sentinel1_TOPS('[Function-1]') configObj.topo('[Function-2]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n') def unpackStackReferenceSLC(self, safe_dict): swath_path = self.work_dir @@ -320,11 +337,14 @@ class run(object): configObj.Sentinel1_TOPS('[Function-1]') configObj.topo('[Function-2]') configObj.finalize() + + line_cnt = 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n') def unpackSecondarysSLC(self, stackReferenceDate, secondaryList, safe_dict): + line_cnt = 0 for secondary in secondaryList: configName = os.path.join(self.config_path,'config_secondary_'+secondary) outdir = os.path.join(self.work_dir,'secondarys/'+secondary) @@ -337,11 +357,14 @@ class run(object): configObj.outDir = outdir configObj.Sentinel1_TOPS('[Function-1]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, self.numProcess) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName+'\n') def averageBaseline(self, stackReferenceDate, secondaryList): + line_cnt = 0 for secondary in secondaryList: configName = os.path.join(self.config_path,'config_baseline_'+secondary) configObj = config(configName) @@ -351,10 +374,14 @@ class run(object): configObj.baselineFile = os.path.join(self.work_dir,'baselines/' + stackReferenceDate +'_' + secondary + '/' + stackReferenceDate +'_'+ secondary + '.txt') configObj.computeAverageBaseline('[Function-1]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, self.numProcess) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName+'\n') def gridBaseline(self, stackReferenceDate, secondaryList): + + line_cnt = 0 for secondary in secondaryList: configName = os.path.join(self.config_path,'config_baselinegrid_'+secondary) configObj = config(configName) @@ -364,8 +391,10 @@ class run(object): configObj.baselineFile = os.path.join(self.work_dir, 'merged/baselines/' + secondary + '/' + secondary ) configObj.computeGridBaseline('[Function-1]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName+'\n') # also add the reference in itself to be consistent with the SLC dir configName = os.path.join(self.config_path,'config_baselinegrid_reference') configObj = config(configName) @@ -375,8 +404,10 @@ class run(object): configObj.baselineFile = os.path.join(self.work_dir, 'merged/baselines/' + stackReferenceDate + '/' + stackReferenceDate) configObj.computeGridBaseline('[Function-1]') configObj.finalize() + + line_cnt = 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName+'\n') def extractOverlaps(self): @@ -386,6 +417,7 @@ class run(object): def geo2rdr_offset(self, secondaryList, fullBurst='False'): + line_cnt = 0 for secondary in secondaryList: reference = self.reference_date if fullBurst == 'True': @@ -407,10 +439,14 @@ class run(object): configObj.overlapTrueOrFalse = 'True' configObj.geo2rdr('[Function-1]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, self.numProcess) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n') def resample_with_carrier(self, secondaryList, fullBurst='False'): + + line_cnt = 0 for secondary in secondaryList: reference = self.reference_date if fullBurst == 'True': @@ -433,13 +469,17 @@ class run(object): configObj.overlapTrueOrFalse = 'True' configObj.resamp_withCarrier('[Function-1]') configObj.finalize() + + line_cnt += 1 + line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, self.numProcess) del configObj - self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n') + def pairs_misregistration(self, dateList, safe_dict): # generating overlap interferograms, estimate azimuth misregistration for each pair: pairs = [] num_overlap_connections = int(self.num_overlap_connections) + 1 + for i in range(len(dateList)-1): for j in range(i+1,i+num_overlap_connections): if j Date: Mon, 8 Feb 2021 10:07:41 -0800 Subject: [PATCH 2/3] GPUtopozero: change isnan reference for compatibility with gcc<6 (#229) --- components/zerodop/GPUtopozero/src/AkimaLib.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/zerodop/GPUtopozero/src/AkimaLib.cpp b/components/zerodop/GPUtopozero/src/AkimaLib.cpp index 7f4ce8e..e663c92 100644 --- a/components/zerodop/GPUtopozero/src/AkimaLib.cpp +++ b/components/zerodop/GPUtopozero/src/AkimaLib.cpp @@ -9,14 +9,13 @@ #include #include -#include +#include #include #include "AkimaLib.h" #include "Constants.h" using std::max; using std::min; using std::vector; -using std::isnan; bool AkimaLib::aki_almostEqual(double x, double y) { bool ret = (abs(x - y) <= AKI_EPS) ? true : false; // Compressed version is a little cleaner From a7c28ddc586309f4ca51e6e9adf0210a3c043ba5 Mon Sep 17 00:00:00 2001 From: Lijun Zhu Date: Tue, 9 Feb 2021 09:40:35 -0800 Subject: [PATCH 3/3] GPU modules: add GPU_ACC_ENABLED flag to cmake --- components/zerodop/GPUampcor/CMakeLists.txt | 5 ++++- components/zerodop/GPUgeo2rdr/CMakeLists.txt | 5 ++++- components/zerodop/GPUresampslc/CMakeLists.txt | 3 +++ components/zerodop/GPUtopozero/CMakeLists.txt | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/zerodop/GPUampcor/CMakeLists.txt b/components/zerodop/GPUampcor/CMakeLists.txt index 6c6b95a..c9b30a8 100644 --- a/components/zerodop/GPUampcor/CMakeLists.txt +++ b/components/zerodop/GPUampcor/CMakeLists.txt @@ -11,9 +11,12 @@ cython_add_module(GPUampcor src/AmpcorFFT.cpp src/AmpcorMethods.cpp ) -target_include_directories(GPUampcor PUBLIC +target_include_directories(GPUampcor PRIVATE include ) +target_compile_definitions(GPUampcor PRIVATE + GPU_ACC_ENABLED + ) target_link_libraries(GPUampcor PRIVATE CUDA::cublas isce2::DataAccessorLib diff --git a/components/zerodop/GPUgeo2rdr/CMakeLists.txt b/components/zerodop/GPUgeo2rdr/CMakeLists.txt index 531fb8a..07afdef 100644 --- a/components/zerodop/GPUgeo2rdr/CMakeLists.txt +++ b/components/zerodop/GPUgeo2rdr/CMakeLists.txt @@ -8,9 +8,12 @@ cython_add_module(GPUgeo2rdr src/Orbit.cpp src/Poly1d.cpp ) -target_include_directories(GPUgeo2rdr PUBLIC +target_include_directories(GPUgeo2rdr PRIVATE include ) +target_compile_definitions(GPUgeo2rdr PRIVATE + GPU_ACC_ENABLED + ) target_link_libraries(GPUgeo2rdr PRIVATE isce2::DataAccessorLib ) diff --git a/components/zerodop/GPUresampslc/CMakeLists.txt b/components/zerodop/GPUresampslc/CMakeLists.txt index 4dbb1bf..c1749d0 100644 --- a/components/zerodop/GPUresampslc/CMakeLists.txt +++ b/components/zerodop/GPUresampslc/CMakeLists.txt @@ -9,6 +9,9 @@ cython_add_module(GPUresampslc target_include_directories(GPUresampslc PRIVATE include ) +target_compile_definitions(GPUresampslc PRIVATE + GPU_ACC_ENABLED + ) target_link_libraries(GPUresampslc PRIVATE isce2::DataAccessorLib OpenMP::OpenMP_CXX diff --git a/components/zerodop/GPUtopozero/CMakeLists.txt b/components/zerodop/GPUtopozero/CMakeLists.txt index f019e20..855a08a 100644 --- a/components/zerodop/GPUtopozero/CMakeLists.txt +++ b/components/zerodop/GPUtopozero/CMakeLists.txt @@ -16,6 +16,9 @@ cython_add_module(GPUtopozero target_include_directories(GPUtopozero PRIVATE include ) +target_compile_definitions(GPUtopozero PRIVATE + GPU_ACC_ENABLED + ) target_link_libraries(GPUtopozero PRIVATE isce2::DataAccessorLib OpenMP::OpenMP_CXX