Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

OpenMP Support

ROUP provides comprehensive support for OpenMP 6.0 directives and clauses for C/C++ and Fortran.


Quick Summary

FeatureSupport
OpenMP Version3.0 - 6.0
Directives95 directives (core + combined forms)
Clauses91 clauses
LanguagesC, C++, Fortran
Test Coverage355 automated tests
SpecificationOpenMP 6.0 PDF

ROUP supports the vast majority of OpenMP 3.0-6.0 directives and clauses.


Directive Support

Core Parallelism (15 directives)

DirectiveExampleNotes
parallel#pragma omp parallelBasic parallel region
for#pragma omp forWork-sharing loop
sections#pragma omp sectionsWork-sharing sections
section#pragma omp sectionIndividual section
single#pragma omp singleSingle-thread execution
master#pragma omp masterMaster thread only
masked#pragma omp maskedMasked execution (OpenMP 5.1+)
barrier#pragma omp barrierSynchronization barrier
critical#pragma omp criticalCritical section
atomic#pragma omp atomicAtomic operation
flush#pragma omp flushMemory fence
ordered#pragma omp orderedOrdered execution
simd#pragma omp simdSIMD vectorization
loop#pragma omp loopGeneric loop (OpenMP 5.0+)
scope#pragma omp scopeScoped region (OpenMP 5.1+)

Tasking (10 directives)

DirectiveExampleNotes
task#pragma omp taskExplicit task
taskwait#pragma omp taskwaitWait for child tasks
taskyield#pragma omp taskyieldYield to other tasks
taskgroup#pragma omp taskgroupTask group
taskloop#pragma omp taskloopTask-generating loop
taskloop simd#pragma omp taskloop simdSIMD taskloop
taskgraph#pragma omp taskgraphTask graph (OpenMP 6.0)
cancel#pragma omp cancelCancel construct
cancellation point#pragma omp cancellation pointCancellation check
depobj#pragma omp depobjDependency object

Device Offloading (12 directives)

DirectiveExampleNotes
target#pragma omp targetOffload to device
target data#pragma omp target dataData environment
target enter data#pragma omp target enter dataMap to device
target exit data#pragma omp target exit dataUnmap from device
target update#pragma omp target updateUpdate data
teams#pragma omp teamsTeam of threads
distribute#pragma omp distributeDistribute iterations
declare target#pragma omp declare targetDevice function
begin declare target#pragma omp begin declare targetBegin target block
end declare target#pragma omp end declare targetEnd target block
interop#pragma omp interopInteroperability (OpenMP 5.1+)
dispatch#pragma omp dispatchDynamic dispatch (OpenMP 5.1+)

Combined Directives (60+ forms)

ROUP supports all standard combined directives:

Parallel + Worksharing:

  • parallel for
  • parallel for simd
  • parallel loop
  • parallel sections
  • parallel master
  • parallel masked

Target + Parallel:

  • target parallel
  • target parallel for
  • target parallel for simd
  • target parallel loop
  • target teams
  • target teams distribute
  • target teams distribute parallel for
  • target teams distribute parallel for simd

Teams + Distribute:

  • teams distribute
  • teams distribute simd
  • teams distribute parallel for
  • teams distribute parallel for simd
  • teams loop

And many more... (all 120+ combinations from OpenMP 6.0)

Meta-directives & Variants (5 directives)

DirectiveExampleNotes
metadirective#pragma omp metadirective when(...)Conditional directive selection
declare variant#pragma omp declare variant(...)Function variants
declare simd#pragma omp declare simdSIMD function
declare reduction#pragma omp declare reductionCustom reduction
declare mapper#pragma omp declare mapperCustom mapper

Utility Directives (6 directives)

DirectiveExampleNotes
threadprivate#pragma omp threadprivate(var)Thread-private data
assume#pragma omp assumeCompiler hints (OpenMP 5.1+)
nothing#pragma omp nothingNo-op directive
error#pragma omp errorCompilation error
requires#pragma omp requiresImplementation requirements
allocate#pragma omp allocateMemory allocation

Clause Support (92 clauses)

Data-Sharing Clauses (8)

ClauseExampleDescription
privateprivate(x, y)Private variables
sharedshared(a, b)Shared variables
firstprivatefirstprivate(z)Private with initialization
lastprivatelastprivate(result)Private with final value
reductionreduction(+:sum)Reduction operation
in_reductionin_reduction(+:total)Participating reduction
task_reductiontask_reduction(*:product)Task reduction
copyincopyin(global_var)Copy to private

Control Clauses (15)

ClauseExampleDescription
ifif(condition)Conditional execution
num_threadsnum_threads(8)Thread count
defaultdefault(shared)Default data-sharing
scheduleschedule(static, 100)Loop scheduling
collapsecollapse(2)Nest loop collapsing
orderedorderedOrdered execution
nowaitnowaitRemove implicit barrier
finalfinal(expr)Final task
untieduntiedUntied task
mergeablemergeableMergeable task
prioritypriority(10)Task priority
grainsizegrainsize(1000)Taskloop grainsize
num_tasksnum_tasks(100)Taskloop task count
nogroupnogroupNo taskgroup
filterfilter(thread_num)Masked filter

Device Clauses (15)

ClauseExampleDescription
devicedevice(gpu_id)Target device
mapmap(to: input)Data mapping
toto(data)Map to device
fromfrom(results)Map from device
defaultmapdefaultmap(tofrom:scalar)Default mapping
is_device_ptris_device_ptr(ptr)Device pointer
use_device_ptruse_device_ptr(ptr)Use device pointer
use_device_addruse_device_addr(var)Use device address
device_residentdevice_resident(var)Device-resident data
num_teamsnum_teams(16)Number of teams
thread_limitthread_limit(256)Threads per team
dist_scheduledist_schedule(static)Distribution schedule
interopinterop(...)Interoperability
device_typedevice_type(gpu)Device type selector
initinit(...)Initialize interop

SIMD Clauses (8)

ClauseExampleDescription
simdlensimdlen(8)SIMD lane count
safelensafelen(16)Safe iteration count
alignedaligned(ptr:32)Alignment
linearlinear(i:1)Linear variable
uniformuniform(step)Uniform across lanes
nontemporalnontemporal(a, b)Non-temporal access
inbranchinbranchIn-branch SIMD
notinbranchnotinbranchNot-in-branch SIMD

Synchronization & Memory (12)

ClauseExampleDescription
dependdepend(in: x)Task dependencies
doacrossdoacross(source:)Cross-iteration dependencies
detachdetach(event)Detachable task
atomic_default_mem_orderatomic_default_mem_order(seq_cst)Default memory order
seq_cstseq_cstSequential consistency
acq_relacq_relAcquire-release
acquireacquireAcquire
releasereleaseRelease
relaxedrelaxedRelaxed
comparecompareCompare atomic
failfail(relaxed)Failure memory order
weakweakWeak compare

Metadirective & Variant Clauses (5)

ClauseExampleDescription
whenwhen(device:{kind(gpu)})Condition selector
matchmatch(construct={...})Trait matching
novariantsnovariantsNo variants
holdsholds(...)Assumption holds
bindbind(thread)Binding

Miscellaneous Clauses (29)

ClauseExampleDescription
allocateallocate(allocator:ptr)Memory allocator
allocatorallocator(omp_default_mem_alloc)Allocator
uses_allocatorsuses_allocators(...)Allocator list
affinityaffinity(...)Thread affinity
proc_bindproc_bind(close)Processor binding
orderorder(concurrent)Loop iteration order
partialpartial(4)Partial unroll
sizessizes(8, 16)Tile sizes
tiletile(...)Loop tiling
unrollunroll(4)Loop unrolling
labellabel(...)Dispatch label
messagemessage("error text")Error message
copyprivatecopyprivate(x)Copy-private
linklink(...)Declare target link
capturecaptureAtomic capture
updateupdateAtomic update
hinthint(...)Performance hint
destroydestroyDestroy clause
reversereverseReverse dependencies
inclusiveinclusive(...)Inclusive scan
exclusiveexclusive(...)Exclusive scan
unified_addressunified_addressRequires clause
unified_shared_memoryunified_shared_memoryRequires clause
dynamic_allocatorsdynamic_allocatorsRequires clause
reproduciblereproducibleOrder modifier
no_openmpno_openmpVariant selector
no_openmp_routinesno_openmp_routinesVariant selector
no_parallelismno_parallelismVariant selector
publicpublicDeclare mapper

Version Compatibility

OpenMP VersionROUP SupportKey Features
6.0 (2024)✅ Fulltaskgraph, dispatch, new loop constructs
5.2 (2021)✅ Fullscope, masked, device extensions
5.1 (2020)✅ Fullassume, nothing, metadirective enhancements
5.0 (2018)✅ Fullloop, requires, memory allocators
4.5 (2015)✅ FullTask dependencies, device constructs
4.0 (2013)✅ FullTasking, SIMD, device offloading

ROUP tracks the latest OpenMP specification and is updated with each new release.


Language Support

C/C++ Syntax

#pragma omp parallel for num_threads(4) schedule(static)
for (int i = 0; i < n; i++) {
    process(i);
}

Supported: All C/C++ #pragma omp directives

Fortran Syntax

!$omp parallel do schedule(dynamic)
do i = 1, n
    call process(i)
end do
!$omp end parallel do

Supported: Free-form (!$omp), Fixed-form (c$omp, *$omp)
Case insensitive: !$OMP, !$Omp, !$omp all work


Test Coverage

ROUP includes comprehensive automated testing:

Test SuiteCountCoverage
Integration tests116Directive parsing, clause combinations
Doc tests239API examples, edge cases
Total355All directives + clauses tested

Every directive and clause in OpenMP 6.0 has a passing test.

See tests/ directory for the full test suite.


Unsupported Features

ROUP focuses on directive parsing, not runtime semantics. The following are out of scope:

Runtime execution - ROUP parses directives, doesn't execute them
Code transformation - No AST rewriting or code generation
Semantic validation - Doesn't check if directives make logical sense
Context analysis - Doesn't validate directive placement in code

Use ROUP for:

  • ✅ Static analysis tools
  • ✅ Code documentation generators
  • ✅ IDE syntax highlighting
  • ✅ Linting and code quality checks
  • ✅ Migration tools
  • ✅ Research prototypes

Don't use ROUP for:

  • ❌ Compiling OpenMP to executables (use GCC/Clang)
  • ❌ Runtime task scheduling (use OpenMP runtime)
  • ❌ Performance profiling (use performance tools)

Implementation Status

ComponentStatusNotes
Lexer✅ CompleteHandles C/C++/Fortran syntax
Parser✅ Completenom-based combinator parser
IR (Intermediate Representation)✅ CompleteType-safe Rust AST
C FFI✅ CompletePointer-based API (16 functions)
Fortran support✅ CompleteAll comment styles
Error messages✅ CompleteDescriptive parse errors
Round-trip✅ CompleteIR → String preservation

Future Additions

Tracking future OpenMP specifications:

VersionStatusExpected Features
OpenMP 6.1📋 PlannedTBD by OpenMP ARB
OpenMP 7.0📋 FutureTBD

ROUP will be updated as new OpenMP versions are released.


References


Summary

ROUP provides OpenMP 3.0-6.0 parsing support:

  • 95 directives (core, combined, and meta-directives)
  • 91 clause types (data-sharing, control, device, SIMD, sync, etc.)
  • C/C++/Fortran syntax support
  • 352 automated tests (comprehensive directive/clause coverage)
  • Type-safe Rust API + C FFI
  • Latest spec (OpenMP 6.0, 2024)

⚠️ Experimental - for research, education, and prototype tooling. Not yet production-ready. 🧪