discopop-library 0.0.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. discopop_library-0.0.1a1/LICENSE +29 -0
  2. discopop_library-0.0.1a1/PKG-INFO +62 -0
  3. discopop_library-0.0.1a1/README.md +18 -0
  4. discopop_library-0.0.1a1/VERSION +1 -0
  5. discopop_library-0.0.1a1/discopop_library/Aliases/__init__.py +0 -0
  6. discopop_library-0.0.1a1/discopop_library/Aliases/aliases.py +9 -0
  7. discopop_library-0.0.1a1/discopop_library/ArgumentClasses/GeneralArguments.py +18 -0
  8. discopop_library-0.0.1a1/discopop_library/CodeGenerator/CodeGenerator.py +206 -0
  9. discopop_library-0.0.1a1/discopop_library/CodeGenerator/CodeGeneratorArguments.py +29 -0
  10. discopop_library-0.0.1a1/discopop_library/CodeGenerator/__init__.py +0 -0
  11. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/ContentBuffer.py +253 -0
  12. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/Enums.py +26 -0
  13. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/Line.py +27 -0
  14. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/Pragma.py +24 -0
  15. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/UnpackedSuggestion.py +568 -0
  16. discopop_library-0.0.1a1/discopop_library/CodeGenerator/classes/__init__.py +0 -0
  17. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/ArgumentClasses.py +39 -0
  18. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/GEPDependencyRemover.py +56 -0
  19. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/Types.py +9 -0
  20. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/__init__.py +0 -0
  21. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/__main__.py +44 -0
  22. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/GEPDependencyRemover/utils.py +25 -0
  23. discopop_library-0.0.1a1/discopop_library/Compatibility/LegacyDiscoPoP/__init__.py +0 -0
  24. discopop_library-0.0.1a1/discopop_library/ConfigProvider/ConfigProviderArguments.py +27 -0
  25. discopop_library-0.0.1a1/discopop_library/ConfigProvider/__init__.py +0 -0
  26. discopop_library-0.0.1a1/discopop_library/ConfigProvider/__main__.py +48 -0
  27. discopop_library-0.0.1a1/discopop_library/ConfigProvider/assets/__init__.py +0 -0
  28. discopop_library-0.0.1a1/discopop_library/ConfigProvider/assets/build_config.py +16 -0
  29. discopop_library-0.0.1a1/discopop_library/ConfigProvider/config_provider.py +49 -0
  30. discopop_library-0.0.1a1/discopop_library/DependencyComparator/DependencyComparatorArguments.py +21 -0
  31. discopop_library-0.0.1a1/discopop_library/DependencyComparator/__main__.py +56 -0
  32. discopop_library-0.0.1a1/discopop_library/DependencyComparator/dependency_comparator.py +114 -0
  33. discopop_library-0.0.1a1/discopop_library/DependencyMetadata/compare_metadata.py +49 -0
  34. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/ArgumentClasses.py +66 -0
  35. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/Autotuner.py +293 -0
  36. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/Classes/CodeConfiguration.py +228 -0
  37. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/Classes/ExecutionResult.py +33 -0
  38. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/Statistics/StatisticsGraph.py +79 -0
  39. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/Types.py +9 -0
  40. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/__init__.py +0 -0
  41. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/__main__.py +71 -0
  42. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/check_single_combination.py +138 -0
  43. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/evolutionary_combination.py +644 -0
  44. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/linear_hotspot_combination.py +101 -0
  45. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/linear_hotspot_combination_with_refinement.py +171 -0
  46. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/measure_only.py +100 -0
  47. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/optimization/parallel_region_combination_with_refinement.py +176 -0
  48. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/output/intermediate.py +51 -0
  49. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/priorities.py +48 -0
  50. discopop_library-0.0.1a1/discopop_library/EmpiricalAutotuning/utils.py +21 -0
  51. discopop_library-0.0.1a1/discopop_library/FolderStructure/__init__.py +0 -0
  52. discopop_library-0.0.1a1/discopop_library/FolderStructure/setup.py +104 -0
  53. discopop_library-0.0.1a1/discopop_library/FolderStructure/teardown.py +83 -0
  54. discopop_library-0.0.1a1/discopop_library/GlobalLogger/setup.py +38 -0
  55. discopop_library-0.0.1a1/discopop_library/HostpotLoader/HotspotLoaderArguments.py +51 -0
  56. discopop_library-0.0.1a1/discopop_library/HostpotLoader/HotspotNodeType.py +23 -0
  57. discopop_library-0.0.1a1/discopop_library/HostpotLoader/HotspotType.py +25 -0
  58. discopop_library-0.0.1a1/discopop_library/HostpotLoader/hostpot_loader.py +60 -0
  59. discopop_library-0.0.1a1/discopop_library/HostpotLoader/utilities.py +82 -0
  60. discopop_library-0.0.1a1/discopop_library/JSONHandler/JSONHandler.py +32 -0
  61. discopop_library-0.0.1a1/discopop_library/JSONHandler/__init__.py +0 -0
  62. discopop_library-0.0.1a1/discopop_library/LineMapping/__init__.py +0 -0
  63. discopop_library-0.0.1a1/discopop_library/LineMapping/delete.py +16 -0
  64. discopop_library-0.0.1a1/discopop_library/LineMapping/diff_modifications.py +155 -0
  65. discopop_library-0.0.1a1/discopop_library/LineMapping/initialize.py +40 -0
  66. discopop_library-0.0.1a1/discopop_library/LineMapping/load.py +18 -0
  67. discopop_library-0.0.1a1/discopop_library/LineMapping/save.py +17 -0
  68. discopop_library-0.0.1a1/discopop_library/MemoryRegions/__init__.py +0 -0
  69. discopop_library-0.0.1a1/discopop_library/MemoryRegions/utils.py +39 -0
  70. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/ArgumentClasses.py +60 -0
  71. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/ParallelRegionMerger.py +87 -0
  72. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/Types.py +9 -0
  73. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/__init__.py +0 -0
  74. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/__main__.py +49 -0
  75. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/CallEdge.py +13 -0
  76. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ContainsEdge.py +13 -0
  77. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/DataflowEdge.py +17 -0
  78. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/DoallModifierNode.py +20 -0
  79. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/Edge.py +14 -0
  80. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/EnterParallelNode.py +42 -0
  81. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ExitParallelNode.py +19 -0
  82. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/FinalEdge.py +13 -0
  83. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/FriendlyModifierNode.py +16 -0
  84. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/IntermediateEdge.py +13 -0
  85. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ModifierEdge.py +13 -0
  86. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ModifierNode.py +13 -0
  87. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ParallelRegionConnectionEdge.py +14 -0
  88. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/ReductionModifierNode.py +20 -0
  89. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/SuccessorEdge.py +13 -0
  90. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/TGFunctionNode.py +20 -0
  91. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/TGLoopNode.py +22 -0
  92. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/TGNode.py +14 -0
  93. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/TaskGraph.py +679 -0
  94. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/TaskNode.py +25 -0
  95. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/TaskGraph/__init__.py +0 -0
  96. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/classes/__init__.py +0 -0
  97. discopop_library-0.0.1a1/discopop_library/ParallelRegionMerger/inflated_parallel_region_pattern.py +593 -0
  98. discopop_library-0.0.1a1/discopop_library/PatchApplicator/PatchApplicatorArguments.py +53 -0
  99. discopop_library-0.0.1a1/discopop_library/PatchApplicator/__init__.py +0 -0
  100. discopop_library-0.0.1a1/discopop_library/PatchApplicator/__main__.py +75 -0
  101. discopop_library-0.0.1a1/discopop_library/PatchApplicator/apply.py +162 -0
  102. discopop_library-0.0.1a1/discopop_library/PatchApplicator/clear.py +37 -0
  103. discopop_library-0.0.1a1/discopop_library/PatchApplicator/list.py +17 -0
  104. discopop_library-0.0.1a1/discopop_library/PatchApplicator/load.py +38 -0
  105. discopop_library-0.0.1a1/discopop_library/PatchApplicator/patch_applicator.py +78 -0
  106. discopop_library-0.0.1a1/discopop_library/PatchApplicator/rollback.py +168 -0
  107. discopop_library-0.0.1a1/discopop_library/PatchGenerator/PatchGeneratorArguments.py +46 -0
  108. discopop_library-0.0.1a1/discopop_library/PatchGenerator/__init__.py +0 -0
  109. discopop_library-0.0.1a1/discopop_library/PatchGenerator/__main__.py +108 -0
  110. discopop_library-0.0.1a1/discopop_library/PatchGenerator/diffs.py +67 -0
  111. discopop_library-0.0.1a1/discopop_library/PatchGenerator/from_json_patterns.py +115 -0
  112. discopop_library-0.0.1a1/discopop_library/PatchGenerator/from_optimizer_output.py +101 -0
  113. discopop_library-0.0.1a1/discopop_library/PatchGenerator/patch_generator.py +65 -0
  114. discopop_library-0.0.1a1/discopop_library/PathManagement/PathManagement.py +48 -0
  115. discopop_library-0.0.1a1/discopop_library/PathManagement/__init__.py +0 -0
  116. discopop_library-0.0.1a1/discopop_library/PatternIdManagement/unique_pattern_id.py +15 -0
  117. discopop_library-0.0.1a1/discopop_library/PreProcessor/PreProcessorArguments.py +25 -0
  118. discopop_library-0.0.1a1/discopop_library/PreProcessor/__init__.py +0 -0
  119. discopop_library-0.0.1a1/discopop_library/PreProcessor/__main__.py +45 -0
  120. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/data_xml.py +72 -0
  121. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/dependency_metadata.py +84 -0
  122. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/driver.py +42 -0
  123. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/dynamic_dependencies.py +112 -0
  124. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/reduction.py +74 -0
  125. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/static_dependencies.py +112 -0
  126. discopop_library-0.0.1a1/discopop_library/PreProcessor/demangle/utilities.py +26 -0
  127. discopop_library-0.0.1a1/discopop_library/PreProcessor/pre_processor.py +41 -0
  128. discopop_library-0.0.1a1/discopop_library/ProjectManager/ProjectManager.py +53 -0
  129. discopop_library-0.0.1a1/discopop_library/ProjectManager/ProjectManagerArguments.py +77 -0
  130. discopop_library-0.0.1a1/discopop_library/ProjectManager/__init__.py +0 -0
  131. discopop_library-0.0.1a1/discopop_library/ProjectManager/__main__.py +79 -0
  132. discopop_library-0.0.1a1/discopop_library/ProjectManager/configurations/copying.py +95 -0
  133. discopop_library-0.0.1a1/discopop_library/ProjectManager/configurations/deletion.py +26 -0
  134. discopop_library-0.0.1a1/discopop_library/ProjectManager/configurations/execution.py +178 -0
  135. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/console.py +107 -0
  136. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/csv.py +98 -0
  137. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/efficiency.py +165 -0
  138. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/execution_time.py +151 -0
  139. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/execution_time_full.py +119 -0
  140. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/full.py +66 -0
  141. discopop_library-0.0.1a1/discopop_library/ProjectManager/reports/speedup.py +161 -0
  142. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/CLI/__init__.py +0 -0
  143. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/CLI/listConfiguration.py +359 -0
  144. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/__init__.py +0 -0
  145. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/deriveSettingsFiles.py +56 -0
  146. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/initializeDirectories.py +33 -0
  147. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/initializeFiles.py +65 -0
  148. discopop_library-0.0.1a1/discopop_library/ProjectManager/utilities/reset.py +41 -0
  149. discopop_library-0.0.1a1/discopop_library/SanityChecker/ArgumentClasses.py +52 -0
  150. discopop_library-0.0.1a1/discopop_library/SanityChecker/Classes/CodeConfiguration.py +146 -0
  151. discopop_library-0.0.1a1/discopop_library/SanityChecker/Classes/ExecutionResult.py +32 -0
  152. discopop_library-0.0.1a1/discopop_library/SanityChecker/SanityChecker.py +144 -0
  153. discopop_library-0.0.1a1/discopop_library/SanityChecker/Types.py +16 -0
  154. discopop_library-0.0.1a1/discopop_library/SanityChecker/__init__.py +0 -0
  155. discopop_library-0.0.1a1/discopop_library/SanityChecker/__main__.py +62 -0
  156. discopop_library-0.0.1a1/discopop_library/SanityChecker/utils.py +25 -0
  157. discopop_library-0.0.1a1/discopop_library/Viewer/ViewerArguments.py +27 -0
  158. discopop_library-0.0.1a1/discopop_library/Viewer/__init__.py +0 -0
  159. discopop_library-0.0.1a1/discopop_library/Viewer/__main__.py +50 -0
  160. discopop_library-0.0.1a1/discopop_library/Viewer/suggestions_view.py +69 -0
  161. discopop_library-0.0.1a1/discopop_library/Viewer/viewer.py +27 -0
  162. discopop_library-0.0.1a1/discopop_library/__init__.py +0 -0
  163. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/CostModels/CostModel.py +257 -0
  164. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/CostModels/DataTransfer/DataTransferCosts.py +43 -0
  165. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/CostModels/DataTransfer/__init__.py +0 -0
  166. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/CostModels/__init__.py +0 -0
  167. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/CostModels/utilities.py +424 -0
  168. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/DataTransfers.py +359 -0
  169. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/NewDataTransfers.py +509 -0
  170. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/__init__.py +0 -0
  171. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/calculate_configuration_data_movement.py +54 -0
  172. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/prepare_force_branch_end_data_movement.py +103 -0
  173. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/prepare_forced_data_movement.py +24 -0
  174. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/DataTransfers/prepare_forced_data_movement_prior_to_call.py +91 -0
  175. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/DelaunayInterpolatedMicrobench.py +106 -0
  176. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/ExtrapInterpolatedMicrobench.py +97 -0
  177. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/Microbench.py +113 -0
  178. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/MicrobenchParser.py +49 -0
  179. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/MixedMicrobench.py +69 -0
  180. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/PureDataMicrobench.py +218 -0
  181. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/__init__.py +0 -0
  182. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Microbench/utils.py +59 -0
  183. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/OptimizationGraph.py +219 -0
  184. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/OptimizerArguments.py +55 -0
  185. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/PETParser/DataAccesses/CalculateUpdates.py +7 -0
  186. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/PETParser/DataAccesses/FromCUs.py +74 -0
  187. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/PETParser/DataAccesses/__init__.py +0 -0
  188. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/PETParser/PETParser.py +1509 -0
  189. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/PETParser/__init__.py +0 -0
  190. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/AddRangesToUpdates.py +103 -0
  191. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/LoopInitializationUpdates.py +63 -0
  192. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/RemoveDuplicatedUpdates.py +164 -0
  193. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/RemoveLoopIndexUpdates.py +71 -0
  194. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/RemoveSameDeviceUpdates.py +36 -0
  195. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/UpdateOptimization/main.py +70 -0
  196. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Variables/Experiment.py +146 -0
  197. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Variables/ExperimentUtils.py +247 -0
  198. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/Variables/__init__.py +0 -0
  199. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/__init__.py +0 -0
  200. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/__main__.py +104 -0
  201. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/bindings/__init__.py +0 -0
  202. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/bindings/utilities.py +31 -0
  203. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/__init__.py +0 -0
  204. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/context/ContextObject.py +258 -0
  205. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/context/ContextObjectUtils.py +56 -0
  206. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/context/Update.py +129 -0
  207. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/context/__init__.py +0 -0
  208. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/CallEdge.py +12 -0
  209. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/ChildEdge.py +12 -0
  210. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/DataFlowEdge.py +18 -0
  211. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/GenericEdge.py +17 -0
  212. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/MutuallyExclusiveEdge.py +21 -0
  213. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/OptionEdge.py +21 -0
  214. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/RequirementEdge.py +21 -0
  215. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/SuccessorEdge.py +17 -0
  216. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/TemporaryEdge.py +16 -0
  217. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/edges/__init__.py +0 -0
  218. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/enums/Distributions.py +14 -0
  219. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/enums/__init__.py +0 -0
  220. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextMerge.py +50 -0
  221. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextNode.py +33 -0
  222. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextRestore.py +45 -0
  223. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextSave.py +38 -0
  224. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextSnapshot.py +41 -0
  225. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/ContextSnapshotPop.py +35 -0
  226. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/DeviceSwitch.py +42 -0
  227. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/FunctionReturn.py +19 -0
  228. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/FunctionRoot.py +75 -0
  229. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/GenericNode.py +105 -0
  230. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/Loop.py +137 -0
  231. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/SynchronizationTrigger.py +42 -0
  232. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/Workload.py +152 -0
  233. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/nodes/__init__.py +0 -0
  234. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/Network.py +63 -0
  235. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/System.py +190 -0
  236. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/__init__.py +0 -0
  237. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/devices/CPU.py +30 -0
  238. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/devices/Device.py +99 -0
  239. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/devices/DeviceTypeEnum.py +14 -0
  240. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/devices/GPU.py +37 -0
  241. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/devices/__init__.py +0 -0
  242. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/system/system_utils.py +80 -0
  243. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/types/Aliases.py +10 -0
  244. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/types/DataAccessType.py +61 -0
  245. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/classes/types/__init__.py +0 -0
  246. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/__init__.py +0 -0
  247. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/plotting/CostModels.py +425 -0
  248. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/plotting/__init__.py +0 -0
  249. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/presentation/ChoiceDetails.py +87 -0
  250. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/presentation/OptionTable.py +312 -0
  251. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/presentation/__init__.py +0 -0
  252. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/queries/ValueTableQuery.py +174 -0
  253. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/queries/__init__.py +0 -0
  254. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/widgets/ScrollableFrame.py +49 -0
  255. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/widgets/ScrollableText.py +46 -0
  256. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/gui/widgets/__init__.py +0 -0
  257. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/interactive/interactive_optimizer.py +199 -0
  258. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimization/evaluate.py +125 -0
  259. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimization/evaluate_all_decision_combinations.py +208 -0
  260. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimization/evolutionary_algorithm.py +521 -0
  261. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimization/greedy.py +246 -0
  262. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimization/validation.py +150 -0
  263. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/optimizer.py +313 -0
  264. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/scheduling/__init__.py +0 -0
  265. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/scheduling/workload_delta.py +253 -0
  266. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/__init__.py +0 -0
  267. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/importers/__init__.py +0 -0
  268. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/importers/do_all.py +244 -0
  269. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/importers/main.py +35 -0
  270. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/importers/reduction.py +171 -0
  271. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/optimizers/loop_collapse.py +300 -0
  272. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/suggestions/optimizers/main.py +17 -0
  273. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/MOGUtilities.py +739 -0
  274. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/__init__.py +0 -0
  275. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/insert_device_switch_nodes.py +127 -0
  276. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/optimization/GlobalOptimization/RandomSamples.py +111 -0
  277. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/optimization/GlobalOptimization/__init__.py +0 -0
  278. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/optimization/LocalOptimization/TopDown.py +182 -0
  279. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/optimization/LocalOptimization/__init__.py +0 -0
  280. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/optimization/__init__.py +0 -0
  281. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/simple_utilities.py +20 -0
  282. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/visualization/__init__.py +0 -0
  283. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/visualization/plotting.py +190 -0
  284. discopop_library-0.0.1a1/discopop_library/discopop_optimizer/utilities/visualization/update_graph.py +209 -0
  285. discopop_library-0.0.1a1/discopop_library/global_data/__init__.py +0 -0
  286. discopop_library-0.0.1a1/discopop_library/global_data/version/VERSION +1 -0
  287. discopop_library-0.0.1a1/discopop_library/global_data/version/__init__.py +0 -0
  288. discopop_library-0.0.1a1/discopop_library/global_data/version/utils.py +16 -0
  289. discopop_library-0.0.1a1/discopop_library/py.typed +0 -0
  290. discopop_library-0.0.1a1/discopop_library/result_classes/DetectionResult.py +49 -0
  291. discopop_library-0.0.1a1/discopop_library/result_classes/MergedPattern.py +19 -0
  292. discopop_library-0.0.1a1/discopop_library/result_classes/OptimizerOutputPattern.py +78 -0
  293. discopop_library-0.0.1a1/discopop_library/result_classes/PatternStorage.py +49 -0
  294. discopop_library-0.0.1a1/discopop_library/result_classes/__init__.py +0 -0
  295. discopop_library-0.0.1a1/discopop_library/tools/__init__.py +0 -0
  296. discopop_library-0.0.1a1/discopop_library/tools/update_notifications/__init__.py +0 -0
  297. discopop_library-0.0.1a1/discopop_library/tools/update_notifications/notification_dialog.py +59 -0
  298. discopop_library-0.0.1a1/discopop_library/tools/update_notifications/update_notifier.py +163 -0
  299. discopop_library-0.0.1a1/discopop_library.egg-info/PKG-INFO +62 -0
  300. discopop_library-0.0.1a1/discopop_library.egg-info/SOURCES.txt +305 -0
  301. discopop_library-0.0.1a1/discopop_library.egg-info/dependency_links.txt +1 -0
  302. discopop_library-0.0.1a1/discopop_library.egg-info/entry_points.txt +12 -0
  303. discopop_library-0.0.1a1/discopop_library.egg-info/requires.txt +29 -0
  304. discopop_library-0.0.1a1/discopop_library.egg-info/top_level.txt +1 -0
  305. discopop_library-0.0.1a1/discopop_library.egg-info/zip-safe +1 -0
  306. discopop_library-0.0.1a1/pyproject.toml +82 -0
  307. discopop_library-0.0.1a1/setup.cfg +4 -0
@@ -0,0 +1,29 @@
1
+ Copyright © 2015-2020 Technische Universitaet Darmstadt, Darmstadt, Germany
2
+ Copyright © 2018-2020 Iowa State University, Ames, USA
3
+ Copyright © 2012-2015 German Research School for Simulation Sciences GmbH, Juelich/Aachen, Germany
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the names of the copyright holders nor the names of their
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: discopop-library
3
+ Version: 0.0.1a1
4
+ Summary: DiscoPoP Library: shared utilities and tools for the DiscoPoP parallelization framework.
5
+ Author-email: TU Darmstadt and Iowa State University <discopop@lists.parallel.informatik.tu-darmstadt.de>
6
+ Project-URL: Homepage, https://www.discopop.tu-darmstadt.de/
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development
13
+ Requires-Python: >=3.6
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: extrap
17
+ Requires-Dist: filelock
18
+ Requires-Dist: jsonpickle
19
+ Requires-Dist: jsons
20
+ Requires-Dist: matplotlib
21
+ Requires-Dist: networkx
22
+ Requires-Dist: numpy
23
+ Requires-Dist: packaging
24
+ Requires-Dist: plotille
25
+ Requires-Dist: pydot
26
+ Requires-Dist: requests
27
+ Requires-Dist: scipy
28
+ Requires-Dist: setuptools
29
+ Requires-Dist: sympy
30
+ Requires-Dist: sympy_plot_backends
31
+ Requires-Dist: tabulate
32
+ Requires-Dist: termcolor
33
+ Requires-Dist: tqdm
34
+ Provides-Extra: dev
35
+ Requires-Dist: mypy; extra == "dev"
36
+ Requires-Dist: black; extra == "dev"
37
+ Requires-Dist: data-science-types; extra == "dev"
38
+ Requires-Dist: pre-commit; extra == "dev"
39
+ Provides-Extra: ci
40
+ Requires-Dist: mypy; extra == "ci"
41
+ Requires-Dist: black; extra == "ci"
42
+ Requires-Dist: data-science-types; extra == "ci"
43
+ Dynamic: license-file
44
+
45
+ <!--
46
+ /*
47
+ * This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
48
+ *
49
+ * Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
50
+ *
51
+ * This software may be modified and distributed under the terms of
52
+ * the 3-Clause BSD License. See the LICENSE file in the package base
53
+ * directory for details.
54
+ *
55
+ */
56
+ -->
57
+
58
+ # DiscoPoP Library
59
+ TODO add description here!
60
+
61
+ ## License
62
+ © DiscoPoP is available under the terms of the BSD-3-Clause license, as specified in the LICENSE file.
@@ -0,0 +1,18 @@
1
+ <!--
2
+ /*
3
+ * This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
4
+ *
5
+ * Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
6
+ *
7
+ * This software may be modified and distributed under the terms of
8
+ * the 3-Clause BSD License. See the LICENSE file in the package base
9
+ * directory for details.
10
+ *
11
+ */
12
+ -->
13
+
14
+ # DiscoPoP Library
15
+ TODO add description here!
16
+
17
+ ## License
18
+ © DiscoPoP is available under the terms of the BSD-3-Clause license, as specified in the LICENSE file.
@@ -0,0 +1 @@
1
+ 0.0.1a1
@@ -0,0 +1,9 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+
9
+ PatternID = int
@@ -0,0 +1,18 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+ import os.path
9
+ from dataclasses import dataclass
10
+ from typing import List, Optional
11
+
12
+
13
+ @dataclass
14
+ class GeneralArguments(object):
15
+ """Container Class for the arguments passed to tools in the DiscoPoP framework"""
16
+
17
+ log_level: str
18
+ write_log: bool
@@ -0,0 +1,206 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+ from pathlib import Path
9
+ from typing import Dict, List, Optional, Tuple
10
+
11
+ import jsons # type: ignore
12
+
13
+ from discopop_explorer.classes.patterns.PatternInfo import PatternInfo
14
+ from discopop_library.CodeGenerator.classes.ContentBuffer import ContentBuffer
15
+ from discopop_library.CodeGenerator.classes.UnpackedSuggestion import UnpackedSuggestion
16
+ from discopop_library.discopop_optimizer.classes.system.devices.DeviceTypeEnum import DeviceTypeEnum
17
+ from discopop_library.discopop_optimizer.classes.types.Aliases import DeviceID
18
+
19
+
20
+ def from_pattern_info(
21
+ file_mapping: Dict[int, Path],
22
+ patterns_by_type: Dict[str, List[PatternInfo]],
23
+ skip_compilation_check: bool = False,
24
+ compile_check_command: Optional[str] = None,
25
+ CC: str = "clang",
26
+ CXX: str = "clang++",
27
+ ) -> Dict[int, str]:
28
+ """Insert the given parallel patterns into the original source code.
29
+ Returns a dictionary which maps the ID of every modified file to the updated contents of the file.
30
+ This method does not modify the original source code.
31
+ Only fileIDs of files which would be modified occur as keys in the returned dictionary.
32
+ For now, it is assumed that the given patterns are independent of each other, i.e. no nesting exists.
33
+ """
34
+ # convert patterns to json strings so that only a single interface has to be maintained
35
+ pattern_json_strings_by_type: Dict[str, List[str]] = dict()
36
+ for type_str in patterns_by_type:
37
+ if type_str not in pattern_json_strings_by_type:
38
+ pattern_json_strings_by_type[type_str] = []
39
+ for pattern in patterns_by_type[type_str]:
40
+ pattern_json_strings_by_type[type_str].append(pattern.to_json())
41
+ return from_json_strings(
42
+ file_mapping,
43
+ pattern_json_strings_by_type,
44
+ skip_compilation_check=skip_compilation_check,
45
+ compile_check_command=compile_check_command,
46
+ )
47
+
48
+
49
+ def from_json_strings(
50
+ file_mapping: Dict[int, Path],
51
+ pattern_json_strings_by_type: Dict[str, List[str]],
52
+ skip_compilation_check: bool = False,
53
+ compile_check_command: Optional[str] = None,
54
+ CC: str = "clang",
55
+ CXX: str = "clang++",
56
+ contained_patterns: Optional[Dict[str, List[str]]] = None,
57
+ ) -> Dict[int, str]:
58
+ """Insert the parallel patterns described by the given json strings into the original source code.
59
+ Returns a dictionary which maps the ID of every modified file to the updated contents of the file.
60
+ This method does not modify the original source code.
61
+ Only fileIDs of files which would be modified occur as keys in the returned dictionary.
62
+ For now, it is assumed that the given patterns are independent of each other, i.e. no nesting exists.
63
+ """
64
+ # convert pattern_json_strings to UnpackedSuggestion object
65
+ unpacked_suggestions: List[UnpackedSuggestion] = []
66
+ pattern_precedence = [
67
+ "do_all",
68
+ "reduction",
69
+ "device_update",
70
+ "gpu_do_all",
71
+ "gpu_reduction",
72
+ "pipeline",
73
+ "simple_gpu",
74
+ "combined_gpu",
75
+ "parallel_region",
76
+ ]
77
+ for type_str in pattern_precedence:
78
+ if type_str not in pattern_json_strings_by_type:
79
+ continue
80
+ for json_str in pattern_json_strings_by_type[type_str]:
81
+ unpacked_suggestions.append(UnpackedSuggestion(type_str, jsons.loads(json_str)))
82
+
83
+ # create a dictionary mapping fileIds to ContentBuffer elements
84
+ file_id_to_content_buffer: Dict[int, ContentBuffer] = dict()
85
+ # iterate over UnpackedSuggestion objects
86
+ for suggestion in unpacked_suggestions:
87
+
88
+ # create new ContentBuffer if required
89
+ if suggestion.file_id not in file_id_to_content_buffer:
90
+ file_id_to_content_buffer[suggestion.file_id] = ContentBuffer(
91
+ suggestion.file_id, file_mapping[suggestion.file_id]
92
+ )
93
+ # get pragma objects represented by the UnpackedSuggestion
94
+ pragmas = suggestion.get_pragmas(contained_patterns=contained_patterns)
95
+ # add pragmas to the ContentBuffer object which corresponds to the fileId specified in UnpackedSuggestions
96
+ for pragma in pragmas:
97
+ successful = file_id_to_content_buffer[suggestion.file_id].add_pragma(
98
+ file_mapping,
99
+ pragma,
100
+ [],
101
+ skip_compilation_check=skip_compilation_check,
102
+ compile_check_command=compile_check_command,
103
+ CC=CC,
104
+ CXX=CXX,
105
+ )
106
+ # if the addition resulted in a non-compilable file, add the pragma as a comment
107
+ if not successful:
108
+ file_id_to_content_buffer[suggestion.file_id].add_pragma(
109
+ file_mapping,
110
+ pragma,
111
+ [],
112
+ add_as_comment=True,
113
+ compile_check_command=compile_check_command,
114
+ CC=CC,
115
+ CXX=CXX,
116
+ )
117
+
118
+ # create the resulting dictionary by assembling the contents of the ContentBuffer objects
119
+ result_dict: Dict[int, str] = dict()
120
+ for file_id in file_id_to_content_buffer:
121
+ result_dict[file_id] = file_id_to_content_buffer[file_id].get_modified_source_code()
122
+ return result_dict
123
+
124
+
125
+ def from_json_strings_with_mapping(
126
+ file_mapping: Dict[int, Path],
127
+ pattern_json_strings_with_mapping_by_type: Dict[str, List[Tuple[str, DeviceID, Optional[DeviceTypeEnum]]]],
128
+ skip_compilation_check: bool = False,
129
+ compile_check_command: Optional[str] = None,
130
+ CC: str = "clang",
131
+ CXX: str = "clang++",
132
+ host_device_id: int = 0,
133
+ contained_patterns: Optional[Dict[str, List[str]]] = None,
134
+ ) -> Dict[int, str]:
135
+ """Insert the parallel patterns described by the given json strings into the original source code.
136
+ Returns a dictionary which maps the ID of every modified file to the updated contents of the file.
137
+ This method does not modify the original source code.
138
+ Only fileIDs of files which would be modified occur as keys in the returned dictionary.
139
+ For now, it is assumed that the given patterns are independent of each other, i.e. no nesting exists.
140
+ """
141
+ # convert pattern_json_strings to UnpackedSuggestion object
142
+ unpacked_suggestions: List[UnpackedSuggestion] = []
143
+ pattern_precedence = [
144
+ "device_update",
145
+ "do_all",
146
+ "reduction",
147
+ "gpu_do_all",
148
+ "gpu_reduction",
149
+ "pipeline",
150
+ "simple_gpu",
151
+ "combined_gpu",
152
+ "parallel_region",
153
+ ]
154
+ for type_str in pattern_precedence:
155
+ if type_str not in pattern_json_strings_with_mapping_by_type:
156
+ continue
157
+ for json_str, device_id, device_type in pattern_json_strings_with_mapping_by_type[type_str]:
158
+ unpacked_suggestions.append(
159
+ UnpackedSuggestion(
160
+ type_str,
161
+ jsons.loads(json_str),
162
+ device_id=device_id,
163
+ device_type=device_type,
164
+ host_device_id=host_device_id,
165
+ )
166
+ )
167
+
168
+ # create a dictionary mapping fileIds to ContentBuffer elements
169
+ file_id_to_content_buffer: Dict[int, ContentBuffer] = dict()
170
+ # iterate over UnpackedSuggestion objects
171
+ for suggestion in unpacked_suggestions:
172
+ # create new ContentBuffer if required
173
+ if suggestion.file_id not in file_id_to_content_buffer:
174
+ file_id_to_content_buffer[suggestion.file_id] = ContentBuffer(
175
+ suggestion.file_id, file_mapping[suggestion.file_id]
176
+ )
177
+ # get pragma objects represented by the UnpackedSuggestion
178
+ pragmas = suggestion.get_pragmas(contained_patterns=contained_patterns)
179
+ # add pragmas to the ContentBuffer object which corresponds to the fileId specified in UnpackedSuggestions
180
+ for pragma in pragmas:
181
+ successful = file_id_to_content_buffer[suggestion.file_id].add_pragma(
182
+ file_mapping,
183
+ pragma,
184
+ [],
185
+ skip_compilation_check=skip_compilation_check,
186
+ compile_check_command=compile_check_command,
187
+ CC=CC,
188
+ CXX=CXX,
189
+ )
190
+ # if the addition resulted in a non-compilable file, add the pragma as a comment
191
+ if not successful:
192
+ file_id_to_content_buffer[suggestion.file_id].add_pragma(
193
+ file_mapping,
194
+ pragma,
195
+ [],
196
+ add_as_comment=True,
197
+ compile_check_command=compile_check_command,
198
+ CC=CC,
199
+ CXX=CXX,
200
+ )
201
+
202
+ # create the resulting dictionary by assembling the contents of the ContentBuffer objects
203
+ result_dict: Dict[int, str] = dict()
204
+ for file_id in file_id_to_content_buffer:
205
+ result_dict[file_id] = file_id_to_content_buffer[file_id].get_modified_source_code()
206
+ return result_dict
@@ -0,0 +1,29 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+ from dataclasses import dataclass
9
+
10
+
11
+ @dataclass
12
+ class CodeGeneratorArguments(object):
13
+ """Container Class for the arguments passed to the discopop_code_generator"""
14
+
15
+ fmap: str
16
+ json: str
17
+ patterns: str
18
+ outputdir: str
19
+ skip_compilation_check: bool
20
+ compile_check_command: str
21
+
22
+ def __post_init__(self) -> None:
23
+ self.__validate()
24
+
25
+ def __validate(self) -> None:
26
+ pass
27
+
28
+ def __str__(self) -> str:
29
+ return str(self.__dict__)
@@ -0,0 +1,253 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+
9
+ import copy
10
+ import os
11
+ import re
12
+ import shlex
13
+ import subprocess
14
+ from pathlib import Path
15
+ from typing import List, Dict, Any, Optional
16
+
17
+ from discopop_library.CodeGenerator.classes.Enums import PragmaPosition
18
+ from discopop_library.CodeGenerator.classes.Line import Line
19
+ from discopop_library.CodeGenerator.classes.Pragma import Pragma
20
+
21
+
22
+ class ContentBuffer(object):
23
+ lines: List[Line]
24
+ max_line_num: int # used to determine width of padding
25
+ file_id: int
26
+ next_free_region_id = 0
27
+ line_type: Any
28
+ compile_result_buffer: str
29
+
30
+ def __init__(self, file_id: int, source_code_path: Path, tab_width: int = 4, line_type: Any = Line) -> None:
31
+ self.line_type = line_type
32
+ self.file_id = file_id
33
+ self.lines = []
34
+ self.max_line_num = 0
35
+ # load source code
36
+ with open(source_code_path, "r") as f:
37
+ lines = f.readlines()
38
+ for idx, line in enumerate(lines):
39
+ idx = idx + 1 # start with line number 1
40
+ self.max_line_num = idx
41
+ line_obj = self.line_type(idx, line_num=idx, content=line)
42
+ self.lines.append(line_obj)
43
+ self.compile_result_buffer = ""
44
+
45
+ def print_lines(self) -> None:
46
+ for line in self.lines:
47
+ print(line)
48
+
49
+ def __get_next_free_region_id(self) -> int:
50
+ buffer = self.next_free_region_id
51
+ self.next_free_region_id += 1
52
+ return buffer
53
+
54
+ def get_modified_source_code(self) -> str:
55
+ result = ""
56
+ for line in self.lines:
57
+ if not line.content.endswith("\n"):
58
+ line.content += "\n"
59
+ result += line.content
60
+ return result
61
+
62
+ def append_line_before(self, parent_line_num: int, line: Line, match_indentation: bool = True) -> None:
63
+ """Appends line before the specified parent_line_num"""
64
+ for idx, potential_parent_line in enumerate(self.lines):
65
+ if potential_parent_line.line_num == parent_line_num:
66
+ if match_indentation:
67
+ line.content = potential_parent_line.get_indentation() + line.content
68
+ self.lines.insert(idx, line)
69
+ return
70
+
71
+ def append_line_after(self, parent_line_num: int, line: Line, match_indentation: bool = True) -> None:
72
+ """Appends line after the specified parent_line_num"""
73
+ for idx, potential_parent_line in enumerate(self.lines):
74
+ if potential_parent_line.line_num == parent_line_num:
75
+ if idx + 1 < len(self.lines):
76
+ self.lines.insert(idx + 1, line)
77
+ else:
78
+ self.lines.append(line)
79
+ if match_indentation:
80
+ line.content = potential_parent_line.get_indentation() + line.content
81
+ return
82
+
83
+ def add_pragma(
84
+ self,
85
+ file_mapping: Dict[int, Path],
86
+ pragma: Pragma,
87
+ parent_regions: List[int],
88
+ add_as_comment: bool = False,
89
+ skip_compilation_check: bool = False,
90
+ compile_check_command: Optional[str] = None,
91
+ CC: str = "clang",
92
+ CXX: str = "clang++",
93
+ match_indentation: bool = True,
94
+ ) -> bool:
95
+ """insert pragma into the maintained list of source code lines.
96
+ Returns True if the pragma resulted in a valid (resp. compilable) code transformation.
97
+ Returns False if compilation of the modified code was not possible.
98
+ In this case, no changes will be applied to the ContentBuffer Object."""
99
+ if pragma.start_line is None or pragma.end_line is None:
100
+ raise ValueError("Unsupported start or end line: ", pragma.start_line, "-", pragma.end_line)
101
+ if pragma.file_id is None:
102
+ raise ValueError("Unsupported file_id: ", pragma.file_id)
103
+ if pragma.file_id != self.file_id:
104
+ return True # incorrect target file, ignore the pragma
105
+
106
+ # create backup of ContentBuffer
107
+ backup_lines = copy.deepcopy(self.lines)
108
+ backup_max_line_num = self.max_line_num
109
+ backup_file_id = self.file_id
110
+ backup_next_free_region_id = self.next_free_region_id
111
+
112
+ # construct line
113
+ pragma_line = self.line_type(pragma.start_line)
114
+
115
+ # adding as comment
116
+ if add_as_comment:
117
+ pragma_line.content = "//<DiscoPoP-IGNORED> "
118
+ else:
119
+ pragma_line.content = ""
120
+
121
+ pragma_line.content += pragma.pragma_str
122
+ pragma_line.belongs_to_regions = copy.deepcopy(parent_regions)
123
+ # create new region if necessary
124
+ if len(pragma.children) > 0:
125
+ region_id = self.__get_next_free_region_id()
126
+ pragma_line.owns_region = region_id
127
+ pragma_line.belongs_to_regions.append(region_id)
128
+
129
+ if pragma.pragma_position == PragmaPosition.BEFORE_START:
130
+ self.append_line_before(pragma.start_line, pragma_line)
131
+ elif pragma.pragma_position == PragmaPosition.AFTER_START:
132
+ self.append_line_after(pragma.start_line, pragma_line)
133
+ elif pragma.pragma_position == PragmaPosition.BEFORE_END:
134
+ self.append_line_before(pragma.end_line, pragma_line)
135
+ elif pragma.pragma_position == PragmaPosition.AFTER_END:
136
+ self.append_line_after(pragma.end_line, pragma_line)
137
+ else:
138
+ raise ValueError("Unsupported pragma position: ", pragma.pragma_position)
139
+
140
+ # update belonging information of contained lines
141
+ tmp_start_line = (
142
+ pragma.start_line if pragma.pragma_position == PragmaPosition.BEFORE_START else pragma.start_line + 1
143
+ )
144
+ tmp_end_line = pragma.end_line + 1
145
+ for line_num in range(tmp_start_line, tmp_end_line):
146
+ for line in self.lines:
147
+ if line.line_num == line_num:
148
+ line.belongs_to_regions += [
149
+ n for n in pragma_line.belongs_to_regions if n not in line.belongs_to_regions
150
+ ]
151
+
152
+ # append children to lines (mark as contained in region)
153
+ for child_pragma in pragma.children:
154
+ # set skip_compilation_check to true since compiling children pragmas on their own might not be successful.
155
+ # As an example for that, '#pragma omp declare target' can be mentioned
156
+ successful = self.add_pragma(
157
+ file_mapping,
158
+ child_pragma,
159
+ pragma_line.belongs_to_regions,
160
+ add_as_comment=add_as_comment,
161
+ skip_compilation_check=True,
162
+ compile_check_command=compile_check_command,
163
+ CC=CC,
164
+ CXX=CXX,
165
+ )
166
+
167
+ if not successful:
168
+ print(self.compile_result_buffer)
169
+ self.lines = backup_lines
170
+ self.next_free_region_id = backup_next_free_region_id
171
+ self.file_id = backup_file_id
172
+ self.max_line_num = backup_max_line_num
173
+ return False
174
+
175
+ if skip_compilation_check:
176
+ return True
177
+
178
+ # check if the applied changes resulted in a compilable source code
179
+ # create a temporary file to store the modified file contents
180
+ if str(file_mapping[self.file_id]).endswith(".c"):
181
+ compiler = CC
182
+ tmp_file_name = str(file_mapping[self.file_id]) + ".discopop_tmp.c"
183
+ else:
184
+ compiler = CXX
185
+ tmp_file_name = str(file_mapping[self.file_id]) + ".discopop_tmp.cpp"
186
+ tmp_file_out_name = str(file_mapping[self.file_id]) + ".discopop_tmp.o"
187
+
188
+ with open(tmp_file_name, "w+") as f:
189
+ f.write(self.get_modified_source_code())
190
+ f.flush()
191
+ f.close()
192
+
193
+ if compile_check_command is None:
194
+ result = subprocess.run(
195
+ [compiler, "-c", "-fopenmp", tmp_file_name, "-o", tmp_file_out_name],
196
+ stdout=subprocess.PIPE,
197
+ stderr=subprocess.PIPE,
198
+ )
199
+ else:
200
+ saved_dir = os.getcwd()
201
+ # prepare environment variables if requested
202
+ pattern = re.compile(r"""((?:[^\s\"\']|\"[^\"]*\"|'[^']*')+)""")
203
+ splitted_compile_check_command = pattern.split(compile_check_command)[
204
+ 1::2
205
+ ] # compile_check_command.split(" ")
206
+ print("SPLITTED: ", splitted_compile_check_command)
207
+ to_be_removed = []
208
+ for idx, elem in enumerate(splitted_compile_check_command):
209
+ if "=" in elem and not elem.startswith("-"):
210
+ # set environment variable
211
+ var_name = elem[: elem.index("=")]
212
+ var_value = elem[elem.index("=") + 1 :]
213
+ print("SET ENVIRONMENT VAR: ")
214
+ print("\t", var_name)
215
+ print("\t\t", var_value)
216
+ # unpack var_value
217
+ if var_value.startswith('"') and var_value.endswith('"') and len(var_value) > 1:
218
+ var_value = var_value[1:-1]
219
+ os.environ[var_name] = var_value
220
+
221
+ to_be_removed.append(idx)
222
+ for idx in sorted(to_be_removed, reverse=True):
223
+ splitted_compile_check_command.pop(idx)
224
+
225
+ # print("COMPILE COMMAND: ", splitted_compile_check_command)
226
+ # result = subprocess.run(
227
+ # splitted_compile_check_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
228
+ # )
229
+
230
+ print("COMPILE COMMAND: ", shlex.split(compile_check_command))
231
+ result = subprocess.run(shlex.split(compile_check_command), shell=True)
232
+
233
+ os.chdir(saved_dir)
234
+ compilation_successful = result.returncode == 0
235
+
236
+ if os.path.exists(tmp_file_name):
237
+ os.remove(tmp_file_name)
238
+ if compilation_successful:
239
+ if os.path.exists(tmp_file_out_name):
240
+ os.remove(tmp_file_out_name)
241
+
242
+ # if not, reset ContentBuffer to the backup and return False
243
+ if not compilation_successful:
244
+ self.lines = backup_lines
245
+ self.next_free_region_id = backup_next_free_region_id
246
+ self.file_id = backup_file_id
247
+ self.max_line_num = backup_max_line_num
248
+ self.compile_result_buffer += result.stdout.decode("utf-8") + "\n"
249
+ self.compile_result_buffer += result.stderr.decode("utf-8") + "\n"
250
+ self.compile_result_buffer += "==> Skipped pragma insertion due to potential compilation errors!\n"
251
+ print(self.compile_result_buffer)
252
+ return False
253
+ return True
@@ -0,0 +1,26 @@
1
+ # This file is part of the DiscoPoP software (http://www.discopop.tu-darmstadt.de)
2
+ #
3
+ # Copyright (c) 2020, Technische Universitaet Darmstadt, Germany
4
+ #
5
+ # This software may be modified and distributed under the terms of
6
+ # the 3-Clause BSD License. See the LICENSE file in the package base
7
+ # directory for details.
8
+
9
+ from enum import IntEnum
10
+
11
+
12
+ class PragmaPosition(IntEnum):
13
+ BEFORE_START = 0
14
+ AFTER_START = 1
15
+ BEFORE_END = 2
16
+ AFTER_END = 3
17
+
18
+
19
+ class OmpConstructPositioning(IntEnum):
20
+ BEFORE_LINE = 0
21
+ AFTER_LINE = 1
22
+
23
+
24
+ class PragmaType(IntEnum):
25
+ PRAGMA = 1
26
+ REGION = 2