2205-omp2tbb开发笔记

Version 0.0

omp2tbb

2022-05-04 开发测试

整理 OpenMP 5.2 导语

制作测试集合,用来测试各种导语的 LLVM-openmp 对应的导语。

首先位于上层的接口是:

LLVM OMP Stmt

LLVM OPENMPIR OMP CLAUSE Care?(Y/N)
OMPParallelDirective pragma omp parallel Y
OMPSimdDirective pragma omp simd Y
OMPForDirective pragma omp for Y
OMPForSimdDirective pragma omp for simd
OMPSectionsDirective pragma omp sections Y
OMPSectionDirective pragma omp section Y
OMPSingleDirective pragma omp single Y
OMPMasterDirective pragma omp master Y
OMPCriticalDirective pragma omp critical Y
OMPParallelForDirective pragma omp parallel for
OMPParallelForSimdDirective pragma omp parallel for simd
OMPParallelMasterDirective pragma omp parallel master
OMPParallelSectionsDirective pragma omp parallel sections
OMPTaskDirective pragma omp task
OMPTaskyieldDirective pragma omp taskyield
OMPBarrierDirective pragma omp barrier
OMPTaskwaitDirective pragma omp taskwait
OMPTaskgroupDirective pragma omp taskgroup
OMPFlushDirective pragma omp flush
OMPDepobjDirective pragma omp depobj
OMPOrderedDirective pragma omp ordered
OMPAtomicDirective pragma omp atomic
OMPTargetDirective pragma omp target
OMPTargetDataDirective pragma omp target data
OMPTargetEnterDataDirective pragma omp target enter data
OMPTargetExitDataDirective pragma omp target exit data
OMPTargetParallelDirective pragma omp target parallel
OMPTargetParallelForDirective pragma omp target parallel for
OMPTeamsDirective pragma omp teams
OMPCancellationPointDirective pragma omp cancellation point
OMPCancelDirective pragma omp cancel
OMPTaskLoopDirective pragma omp taskloop
OMPTaskLoopSimdDirective pragma omp taskloop simd
OMPMasterTaskLoopDirective pragma omp master taskloop
OMPMasterTaskLoopSimdDirective pragma omp master taskloop simd
OMPParallelMasterTaskLoopDirective pragma omp parallel master taskloop
OMPParallelMasterTaskLoopSimdDirective pragma omp parallel master taskloop simd
OMPDistributeDirective pragma omp distribute
OMPTargetUpdateDirective pragma omp target update
OMPDistributeParallelForDirective pragma omp distribute parallel for
OMPDistributeParallelForSimdDirective pragma omp distribute parallel for simd
OMPDistributeSimdDirective pragma omp distribute simd
OMPTargetParallelForSimdDirective pragma omp target parallel for simd
OMPTargetSimdDirective pragma omp target simd
OMPTeamsDistributeDirective pragma omp teams distribute
OMPTeamsDistributeSimdDirective pragma omp teams distribute simd
OMPTeamsDistributeParallelForSimdDirective pragma omp teams distribute parallel for simd
OMPTeamsDistributeParallelForDirective pragma omp teams distribute parallel for
OMPTargetTeamsDirective pragma omp target teams
OMPTargetTeamsDistributeDirective pragma omp target teams distribute
OMPTargetTeamsDistributeParallelForDirective pragma omp target teams distribute parallel for
OMPTargetTeamsDistributeParallelForSimdDirective pragma omp target teams distribute parallel for simd
OMPTargetTeamsDistributeSimdDirective pragma omp target teams distribute simd
OMPTileDirective pragma omp tile
OMPUnrollDirective pragma omp unroll
OMPScanDirective pragma omp scan
OMPInteropDirective pragma omp interop
OMPDispatchDirective pragma omp dispatch
OMPMaskedDirective pragma omp masked
OMPMetaDirective pragma omp metadirective
OMPGenericLoopDirective pragma omp loop
OMPTeamsGenericLoopDirective pragma omp teams loop
OMPTargetTeamsGenericLoopDirective pragma omp target teams loop
OMPParallelGenericLoopDirective pragma omp parallel loop
OMPTargetParallelGenericLoopDirective pragma omp target parallel loop

作为最上层的识别层,之后下一层的是:

LLVM Decl

LLVM OpenMP Decl openmp decl Care?(Y/N)
OMPAllocatorClause allocator
OMPAlignClause align
OMPAllocateClause allocate
OMPIfClause if
OMPFinalClause final
OMPNumThreadsClause num_threads
OMPSafelenClause safelen
OMPSimdlenClause simdlen
OMPSizesClause sizes
OMPCollapseClause collapse
OMPDefaultClause default
OMPProcBindClause proc_bind
OMPUnifiedAddressClause unified_address
OMPUnifiedSharedMemoryClause unified_shared_memory
OMPReverseOffloadClause reverse_offload
OMPDynamicAllocatorsClause dynamic_allocators
OMPAtomicDefaultMemOrderClause atomic_default_mem_order
OMPScheduleClause schedule
OMPOrderedClause ordered
OMPNowaitClause nowait
OMPUntiedClause untied
OMPMergeableClause mergeable
OMPReadClause read
OMPWriteClause write
OMPUpdateClause update
OMPCaptureClause capture
OMPCompareClause compare
OMPSeqCstClause seq_cst
OMPAcqRelClause acq_rel
OMPAcquireClause acquire
OMPReleaseClause release
OMPRelaxedClause relaxed
OMPPrivateClause private
OMPFirstprivateClause firstprivate
OMPLastprivateClause lastprivate
OMPSharedClause shared
OMPReductionClause reduction
OMPTaskReductionClause task_reduction
OMPInReductionClause in_reduction
OMPLinearClause linear
OMPAlignedClause aligned
OMPCopyinClause copyin
OMPCopyprivateClause copyprivate
OMPFlushClause flush
OMPDepobjClause depobj
OMPDependClause depend
OMPDeviceClause device
OMPThreadsClause threads
OMPSIMDClause simd
OMPMapClause map
OMPNumTeamsClause num_teams
OMPThreadLimitClause thread_limit
OMPPriorityClause priority
OMPGrainsizeClause grainsize
OMPNogroupClause nogroup
OMPNumTasksClause num_tasks
OMPHintClause hint
OMPDistScheduleClause dist_schedule
OMPDefaultmapClause defaultmap
OMPToClause to
OMPFromClause from
OMPUseDevicePtrClause use_device_ptr
OMPUseDeviceAddrClause use_device_addr
OMPIsDevicePtrClause is_device_ptr
OMPHasDeviceAddrClause has_device_ptr
OMPNontemporalClause nontemporal
OMPOrderClause order
OMPInitClause init
OMPUseClause use
OMPDestroyClause destroy
OMPNovariantsClause novariants
OMPNocontextClause nocontext
OMPDetachClause detach
OMPInclusiveClause inclusive
OMPExclusiveClause exclusive
OMPUsesAllocatorsClause uses_allocators
OMPAffinityClause affinity
OMPFilterClause filter
OMPBindClause bind

属实有点多,目前位置我们的目标是:
对于 OpenMP 的代码块,我们识别出”最上层的逻辑块”,之后将其提取成为新的函数。
对于包含了 OpenMP 的函数块,我们也将其提取成”新函数”。

我们给新的函数命名,之后进行我们的代码翻译工作。
首先第一步工作是将并行代码串行化。

Development Step 1

  • [x] 构建可以识别 Stmt 的 Visitor
  • [x] 构建可以识别 OpenMP Directive 的 Visitor ✅ 2022-05-05
  • [x] 找出 OpenMP Directive 的范围,从而找出新的范围 ✅ 2022-05-05

记录:
这里遇到一个非常大的坑点,使用 libclang 开发的工具需要加 — -fopenmp 才能启用编译选项

  • [x] 详细构建 Openmp 的树形结构

Development Step 0

OpenMP Examples Build

顺着 openmp 官方的 example 文档构建 openmp 的并行例子。从而方便我们做之后的优化分析。

例子构建

  • [x] 测试时间工具部署 ✅ 2022-05-11
  • [x] 阅读 Structured Programming Models

分为两类:

  • 构建 bottom 类别
    • 从底层方案出发
  • 构建 top 类别
    • 从上层方案出发

目标:

  • 充分发挥 omp5.2 的特性
  • 使用 omp task 、parallel、for 方便之后进行检测和转化
  • 熟悉 intel tbb 的具体操作和语法

思路!!
产生了新的想法:

  • 如果分析了数据访问的行为模式,分析一维/二维/三维的模式特征
    • 整数泛函
    • NLP 分析表达式特征
  • 为函数/openmp 代码快称重
    • 是否有必要 inline
    • 是否有必要并行
    • NLP?
    • 试一试,生成这个模式的 inline/noinline 代码
  • 针对多重循环
  • 针对随机离散的应用
    • ising model
    • 2 维图片随机的处理
    • SPH
    • Conway 生命游戏

已经成功构建 bottom cases。位于

https://github.com/Chivier/ompfuns

Develop Step 1

测试代码重写。找到一个合适的例子:
upc2c


2205-omp2tbb开发笔记
http://blog.chivier.site/2022-07-01/787e6d2dbc66/
Author
Chivier Humber
Posted on
July 1, 2022
Licensed under