├── .github └── workflows │ └── CI.yml ├── .gitignore ├── .gitmodules ├── CHANGES.txt ├── CMakeLists.txt ├── CREDITS.txt ├── LICENSE.txt ├── README.md ├── README.rst ├── cmake ├── DetectTestCompiler │ └── CMakeLists.txt ├── HandleOpenMPOptions.cmake ├── OpenMPTesting.cmake └── config-ix.cmake ├── docs └── ReleaseNotes.rst ├── examples ├── sample_nested.c ├── sample_task_multiple_producer.c └── sample_task_single_producer.c ├── external └── CMakeLists.txt ├── libomptarget ├── CMakeLists.txt ├── README.txt ├── cmake │ └── Modules │ │ ├── LibomptargetGetDependencies.cmake │ │ ├── LibomptargetNVPTXBitcodeLibrary.cmake │ │ └── LibomptargetUtils.cmake ├── deviceRTLs │ ├── CMakeLists.txt │ ├── amdgcn │ │ ├── CMakeLists.txt │ │ └── src │ │ │ ├── amdgcn_interface.h │ │ │ ├── amdgcn_locks.hip │ │ │ ├── amdgcn_smid.hip │ │ │ ├── target_impl.h │ │ │ └── target_impl.hip │ ├── common │ │ ├── debug.h │ │ ├── device_environment.h │ │ ├── omptarget.h │ │ ├── omptargeti.h │ │ ├── src │ │ │ ├── cancel.cu │ │ │ ├── critical.cu │ │ │ ├── data_sharing.cu │ │ │ ├── libcall.cu │ │ │ ├── loop.cu │ │ │ ├── omp_data.cu │ │ │ ├── omptarget.cu │ │ │ ├── parallel.cu │ │ │ ├── reduction.cu │ │ │ ├── support.cu │ │ │ ├── sync.cu │ │ │ └── task.cu │ │ ├── state-queue.h │ │ ├── state-queuei.h │ │ └── support.h │ ├── interface.h │ └── nvptx │ │ ├── CMakeLists.txt │ │ ├── docs │ │ └── ReductionDesign.txt │ │ ├── src │ │ ├── nvptx_interface.h │ │ ├── target_impl.cu │ │ └── target_impl.h │ │ └── test │ │ ├── CMakeLists.txt │ │ ├── api │ │ ├── get_max_threads.c │ │ ├── ignored.c │ │ ├── max_threads.c │ │ └── thread_limit.c │ │ ├── data_sharing │ │ └── alignment.c │ │ ├── lit.cfg │ │ ├── lit.site.cfg.in │ │ └── parallel │ │ ├── barrier.c │ │ ├── flush.c │ │ ├── level.c │ │ ├── nested.c │ │ ├── num_threads.c │ │ ├── spmd_parallel_regions.cpp │ │ ├── thread_limit.c │ │ └── tripcount.c ├── include │ ├── Debug.h │ ├── SourceInfo.h │ ├── omptarget.h │ └── omptargetplugin.h ├── plugins │ ├── CMakeLists.txt │ ├── aarch64 │ │ └── CMakeLists.txt │ ├── amdgpu │ │ ├── CMakeLists.txt │ │ ├── impl │ │ │ ├── atmi.cpp │ │ │ ├── atmi.h │ │ │ ├── atmi_interop_hsa.cpp │ │ │ ├── atmi_interop_hsa.h │ │ │ ├── atmi_runtime.h │ │ │ ├── data.cpp │ │ │ ├── get_elf_mach_gfx_name.cpp │ │ │ ├── get_elf_mach_gfx_name.h │ │ │ ├── internal.h │ │ │ ├── machine.cpp │ │ │ ├── machine.h │ │ │ ├── msgpack.cpp │ │ │ ├── msgpack.def │ │ │ ├── msgpack.h │ │ │ ├── rt.h │ │ │ ├── system.cpp │ │ │ └── utils.cpp │ │ └── src │ │ │ └── rtl.cpp │ ├── common │ │ ├── CMakeLists.txt │ │ ├── MemoryManager │ │ │ ├── CMakeLists.txt │ │ │ └── MemoryManager.h │ │ └── elf_common │ │ │ ├── CMakeLists.txt │ │ │ └── elf_common.h │ ├── cuda │ │ ├── CMakeLists.txt │ │ └── src │ │ │ └── rtl.cpp │ ├── exports │ ├── generic-elf-64bit │ │ └── src │ │ │ └── rtl.cpp │ ├── ppc64 │ │ └── CMakeLists.txt │ ├── ppc64le │ │ └── CMakeLists.txt │ ├── ve │ │ ├── CMakeLists.txt │ │ └── src │ │ │ └── rtl.cpp │ └── x86_64 │ │ └── CMakeLists.txt ├── src │ ├── CMakeLists.txt │ ├── api.cpp │ ├── device.cpp │ ├── device.h │ ├── exports │ ├── interface.cpp │ ├── omptarget.cpp │ ├── private.h │ ├── rtl.cpp │ └── rtl.h └── test │ ├── CMakeLists.txt │ ├── api │ ├── omp_get_num_devices.c │ └── omp_get_num_devices_with_empty_target.c │ ├── env │ ├── base_ptr_ref_count.c │ └── omp_target_debug.c │ ├── lit.cfg │ ├── lit.site.cfg.in │ ├── mapping │ ├── alloc_fail.c │ ├── declare_mapper_api.cpp │ ├── declare_mapper_target.cpp │ ├── declare_mapper_target_data.cpp │ ├── declare_mapper_target_data_enter_exit.cpp │ ├── declare_mapper_target_update.cpp │ ├── delete_inf_refcount.c │ ├── lambda_mapping.cpp │ ├── pr38704.c │ ├── present │ │ ├── target.c │ │ ├── target_array_extension.c │ │ ├── target_data.c │ │ ├── target_data_array_extension.c │ │ ├── target_data_at_exit.c │ │ ├── target_enter_data.c │ │ ├── target_exit_data.c │ │ ├── target_update.c │ │ ├── target_update_array_extension.c │ │ ├── unified_shared_memory.c │ │ ├── zero_length_array_section.c │ │ └── zero_length_array_section_exit.c │ ├── private_mapping.c │ ├── ptr_and_obj_motion.c │ ├── target_data_array_extension_at_exit.c │ ├── target_implicit_partial_map.c │ └── target_update_array_extension.c │ ├── offloading │ ├── bug47654.cpp │ ├── d2d_memcpy.c │ ├── dynamic_module.c │ ├── dynamic_module_load.c │ ├── info.c │ ├── looptripcnt.c │ ├── memory_manager.cpp │ ├── non_contiguous_update.cpp │ ├── offloading_success.c │ ├── offloading_success.cpp │ ├── parallel_offloading_map.cpp │ ├── requires.c │ └── target_depend_nowait.cpp │ └── unified_shared_memory │ ├── api.c │ ├── close_enter_exit.c │ ├── close_manual.c │ ├── close_modifier.c │ └── shared_update.c ├── maint ├── bolt-release.pl └── update-llvmomp.sh ├── runtime ├── .clang-format ├── CMakeLists.txt ├── README.txt ├── cmake │ ├── LibboltSymlinkArgobots.cmake │ ├── LibompCheckFortranFlag.cmake │ ├── LibompCheckLinkerFlag.cmake │ ├── LibompDefinitions.cmake │ ├── LibompExports.cmake │ ├── LibompGetArchitecture.cmake │ ├── LibompHandleFlags.cmake │ ├── LibompMicroTests.cmake │ ├── LibompUtils.cmake │ └── config-ix.cmake ├── doc │ ├── Reference.pdf │ └── doxygen │ │ ├── config │ │ ├── header.tex │ │ └── libomp_interface.h ├── src │ ├── CMakeLists.txt │ ├── dllexports │ ├── exports_so.txt │ ├── extractExternal.cpp │ ├── i18n │ │ └── en_US.txt │ ├── include │ │ ├── omp-tools.h.var │ │ ├── omp.h.var │ │ ├── omp_lib.f90.var │ │ └── omp_lib.h.var │ ├── kmp.h │ ├── kmp_abt.h │ ├── kmp_abt_affinity.cpp │ ├── kmp_affinity.cpp │ ├── kmp_affinity.h │ ├── kmp_alloc.cpp │ ├── kmp_atomic.cpp │ ├── kmp_atomic.h │ ├── kmp_barrier.cpp │ ├── kmp_cancel.cpp │ ├── kmp_config.h.cmake │ ├── kmp_csupport.cpp │ ├── kmp_debug.cpp │ ├── kmp_debug.h │ ├── kmp_debugger.cpp │ ├── kmp_debugger.h │ ├── kmp_dispatch.cpp │ ├── kmp_dispatch.h │ ├── kmp_dispatch_hier.h │ ├── kmp_environment.cpp │ ├── kmp_environment.h │ ├── kmp_error.cpp │ ├── kmp_error.h │ ├── kmp_ftn_cdecl.cpp │ ├── kmp_ftn_entry.h │ ├── kmp_ftn_extra.cpp │ ├── kmp_ftn_os.h │ ├── kmp_ftn_stdcall.cpp │ ├── kmp_global.cpp │ ├── kmp_gsupport.cpp │ ├── kmp_i18n.cpp │ ├── kmp_i18n.h │ ├── kmp_import.cpp │ ├── kmp_io.cpp │ ├── kmp_io.h │ ├── kmp_itt.cpp │ ├── kmp_itt.h │ ├── kmp_itt.inl │ ├── kmp_lock.cpp │ ├── kmp_lock.h │ ├── kmp_omp.h │ ├── kmp_os.h │ ├── kmp_platform.h │ ├── kmp_runtime.cpp │ ├── kmp_safe_c_api.h │ ├── kmp_sched.cpp │ ├── kmp_settings.cpp │ ├── kmp_settings.h │ ├── kmp_stats.cpp │ ├── kmp_stats.h │ ├── kmp_stats_timing.cpp │ ├── kmp_stats_timing.h │ ├── kmp_str.cpp │ ├── kmp_str.h │ ├── kmp_stub.cpp │ ├── kmp_stub.h │ ├── kmp_taskdeps.cpp │ ├── kmp_taskdeps.h │ ├── kmp_tasking.cpp │ ├── kmp_threadprivate.cpp │ ├── kmp_utility.cpp │ ├── kmp_version.cpp │ ├── kmp_version.h │ ├── kmp_wait_release.cpp │ ├── kmp_wait_release.h │ ├── kmp_wrapper_getpid.h │ ├── kmp_wrapper_malloc.h │ ├── libomp.rc.var │ ├── ompt-event-specific.h │ ├── ompt-general.cpp │ ├── ompt-internal.h │ ├── ompt-specific.cpp │ ├── ompt-specific.h │ ├── test-touch.c │ ├── thirdparty │ │ └── ittnotify │ │ │ ├── disable_warnings.h │ │ │ ├── ittnotify.h │ │ │ ├── ittnotify_config.h │ │ │ ├── ittnotify_static.cpp │ │ │ ├── ittnotify_static.h │ │ │ ├── ittnotify_types.h │ │ │ └── legacy │ │ │ └── ittnotify.h │ ├── tsan_annotations.cpp │ ├── tsan_annotations.h │ ├── z_Linux_asm.S │ ├── z_Linux_util.cpp │ ├── z_Windows_NT-586_asm.asm │ ├── z_Windows_NT-586_util.cpp │ └── z_Windows_NT_util.cpp ├── test │ ├── CMakeLists.txt │ ├── affinity │ │ ├── bug-nested.c │ │ └── format │ │ │ ├── affinity_display.1.c │ │ │ ├── affinity_values.c │ │ │ ├── api.c │ │ │ ├── api2.c │ │ │ ├── check.py │ │ │ ├── fields_modifiers.c │ │ │ ├── fields_values.c │ │ │ ├── increase.c │ │ │ ├── lit.local.cfg │ │ │ ├── nested.c │ │ │ ├── nested2.c │ │ │ ├── nested_mixed.c │ │ │ ├── nested_serial.c │ │ │ ├── proc_bind.c │ │ │ ├── simple.c │ │ │ └── simple_env.c │ ├── api │ │ ├── has_openmp.c │ │ ├── kmp_aligned_malloc.c │ │ ├── kmp_set_defaults_lock_bug.c │ │ ├── omp_alloc_def_fb.c │ │ ├── omp_alloc_hbw.c │ │ ├── omp_alloc_null_fb.c │ │ ├── omp_calloc_def_fb.c │ │ ├── omp_calloc_size_0.c │ │ ├── omp_display_env0.c │ │ ├── omp_get_num_devices.c │ │ ├── omp_get_num_threads.c │ │ ├── omp_get_wtick.c │ │ ├── omp_get_wtime.c │ │ ├── omp_in_parallel.c │ │ ├── omp_pause_resource.c │ │ ├── omp_realloc_def_fb.c │ │ ├── omp_realloc_null_ptr.c │ │ └── omp_realloc_size_0.c │ ├── atomic │ │ └── omp_atomic.c │ ├── barrier │ │ └── omp_barrier.c │ ├── bolt │ │ ├── interop │ │ │ ├── init_then_openmp.c │ │ │ └── openmp_then_init.c │ │ ├── misc_bugs │ │ │ └── untied_tasks.c │ │ ├── scheduling │ │ │ ├── bolt_scheduling_util.h │ │ │ ├── for_nowait_scheduling.c │ │ │ ├── task_tied_scheduling.c │ │ │ ├── task_tied_thread_scheduling.c │ │ │ ├── task_unitied_scheduling.c │ │ │ ├── task_untied_thread_scheduling.c │ │ │ ├── taskdep_taskgroup_tied_scheduling.c │ │ │ ├── taskdep_taskgroup_untied_scheduling.c │ │ │ ├── taskdep_taskgroup_untied_yield_scheduling.c │ │ │ ├── taskdep_taskwait_tied_scheduling.c │ │ │ ├── taskdep_taskwait_untied_scheduling.c │ │ │ ├── taskdep_taskwait_untied_yield_scheduling.c │ │ │ ├── taskdep_tied_scheduling.c │ │ │ ├── taskdep_untied_scheduling.c │ │ │ ├── taskdep_untied_yield_scheduling.c │ │ │ ├── taskloop_nogroup_tied_scheduling.c │ │ │ ├── taskloop_nogroup_untied_scheduling.c │ │ │ ├── taskloop_tied_scheduling.c │ │ │ ├── taskloop_untied_scheduling.c │ │ │ ├── thread_scheduling.c │ │ │ └── thread_thread_scheduling.c │ │ └── threadid │ │ │ ├── task_tied_thread_threadid.c │ │ │ ├── task_tied_threadid.c │ │ │ ├── task_unitied_thread_threadid.c │ │ │ ├── task_untied_threadid.c │ │ │ ├── task_untied_threadid2.c │ │ │ ├── taskdep_tied_threadid.c │ │ │ ├── taskdep_untied_threadid.c │ │ │ ├── taskdep_untied_threadid2.c │ │ │ ├── taskloop_tied_threadid.c │ │ │ ├── taskloop_untied_threadid.c │ │ │ ├── thread_thread_threadid.c │ │ │ └── thread_threadid.c │ ├── critical │ │ └── omp_critical.c │ ├── env │ │ ├── kmp_aff_disable_hwloc.c │ │ ├── kmp_set_dispatch_buf.c │ │ ├── omp_alloc_env_invalid.c │ │ ├── omp_target_offload.c │ │ ├── omp_thread_limit.c │ │ └── omp_wait_policy.c │ ├── flush │ │ └── omp_flush.c │ ├── lit.cfg │ ├── lit.site.cfg.in │ ├── lock │ │ ├── omp_init_lock.c │ │ ├── omp_lock.c │ │ ├── omp_nest_lock.c │ │ ├── omp_test_lock.c │ │ └── omp_test_nest_lock.c │ ├── master │ │ ├── omp_master.c │ │ └── omp_master_3.c │ ├── misc_bugs │ │ ├── cancellation_for_sections.c │ │ ├── for-task-for-task.c │ │ ├── for-task-for.c │ │ ├── many-microtask-args.c │ │ ├── omp_foreign_thread_team_reuse.c │ │ ├── stack-propagate.c │ │ ├── teams-no-par.c │ │ └── teams-reduction.c │ ├── omp_my_sleep.h │ ├── omp_testsuite.h │ ├── ompt │ │ ├── callback.h │ │ ├── cancel │ │ │ ├── cancel_parallel.c │ │ │ ├── cancel_taskgroup.c │ │ │ └── cancel_worksharing.c │ │ ├── loadtool │ │ │ ├── tool_available │ │ │ │ └── tool_available.c │ │ │ ├── tool_available_search │ │ │ │ └── tool_available_search.c │ │ │ └── tool_not_available │ │ │ │ └── tool_not_available.c │ │ ├── misc │ │ │ ├── api_calls_from_other_thread.cpp │ │ │ ├── api_calls_misc.c │ │ │ ├── api_calls_places.c │ │ │ ├── api_calls_without_ompt.c │ │ │ ├── control_tool.c │ │ │ ├── control_tool_no_ompt_support.c │ │ │ ├── finalize_tool.c │ │ │ ├── interoperability.cpp │ │ │ ├── threads.c │ │ │ ├── threads_nested.c │ │ │ └── unset_callback.c │ │ ├── ompt-signal.h │ │ ├── parallel │ │ │ ├── dynamic_enough_threads.c │ │ │ ├── dynamic_not_enough_threads.c │ │ │ ├── max_active_levels_serialized.c │ │ │ ├── nested.c │ │ │ ├── nested_lwt.c │ │ │ ├── nested_serialized.c │ │ │ ├── nested_thread_num.c │ │ │ ├── nested_threadnum.c │ │ │ ├── no_thread_num_clause.c │ │ │ ├── normal.c │ │ │ ├── not_enough_threads.c │ │ │ ├── parallel_if0.c │ │ │ ├── repeated_calls.c │ │ │ └── serialized.c │ │ ├── synchronization │ │ │ ├── barrier │ │ │ │ ├── explicit.c │ │ │ │ ├── for_loop.c │ │ │ │ ├── for_simd.c │ │ │ │ ├── implicit_task_data.c │ │ │ │ ├── parallel_region.c │ │ │ │ ├── sections.c │ │ │ │ └── single.c │ │ │ ├── critical.c │ │ │ ├── flush.c │ │ │ ├── lock.c │ │ │ ├── masked.c │ │ │ ├── master.c │ │ │ ├── nest_lock.c │ │ │ ├── ordered.c │ │ │ ├── ordered_dependences.c │ │ │ ├── reduction │ │ │ │ ├── empty_reduce.c │ │ │ │ └── tree_reduce.c │ │ │ ├── taskgroup.c │ │ │ ├── taskwait.c │ │ │ ├── test_lock.c │ │ │ ├── test_nest_lock.c │ │ │ └── test_nest_lock_parallel.c │ │ ├── tasks │ │ │ ├── dependences.c │ │ │ ├── dependences_mutexinoutset.c │ │ │ ├── explicit_task.c │ │ │ ├── serialized.c │ │ │ ├── task_early_fulfill.c │ │ │ ├── task_if0-depend.c │ │ │ ├── task_in_joinbarrier.c │ │ │ ├── task_late_fulfill.c │ │ │ ├── task_memory.c │ │ │ ├── task_types.c │ │ │ ├── task_types_serialized.c │ │ │ ├── taskloop.c │ │ │ ├── taskwait-depend.c │ │ │ ├── taskyield.c │ │ │ └── untied_task.c │ │ ├── teams │ │ │ ├── parallel_team.c │ │ │ ├── serial_teams.c │ │ │ ├── serialized.c │ │ │ └── team.c │ │ └── worksharing │ │ │ ├── for │ │ │ ├── auto.c │ │ │ ├── auto_serialized.c │ │ │ ├── auto_split.c │ │ │ ├── base.h │ │ │ ├── base_serialized.h │ │ │ ├── base_split.h │ │ │ ├── dynamic.c │ │ │ ├── dynamic_serialized.c │ │ │ ├── dynamic_split.c │ │ │ ├── guided.c │ │ │ ├── guided_serialized.c │ │ │ ├── guided_split.c │ │ │ ├── runtime.c │ │ │ ├── runtime_serialized.c │ │ │ ├── runtime_split.c │ │ │ ├── static.c │ │ │ ├── static_serialized.c │ │ │ └── static_split.c │ │ │ ├── sections.c │ │ │ └── single.c │ ├── parallel │ │ ├── omp_nested.c │ │ ├── omp_parallel_copyin.c │ │ ├── omp_parallel_default.c │ │ ├── omp_parallel_firstprivate.c │ │ ├── omp_parallel_if.c │ │ ├── omp_parallel_num_threads.c │ │ ├── omp_parallel_private.c │ │ ├── omp_parallel_reduction.c │ │ └── omp_parallel_shared.c │ ├── tasking │ │ ├── bug_36720.c │ │ ├── bug_nested_proxy_task.c │ │ ├── bug_proxy_task_dep_waiting.c │ │ ├── bug_serial_taskgroup.c │ │ ├── kmp_detach_tasks_t1.c │ │ ├── kmp_detach_tasks_t2.c │ │ ├── kmp_detach_tasks_t3.c │ │ ├── kmp_task_modifier_simple_par_new.cpp │ │ ├── kmp_task_modifier_simple_par_old.cpp │ │ ├── kmp_task_modifier_simple_ws_new.cpp │ │ ├── kmp_task_modifier_simple_ws_old.cpp │ │ ├── kmp_task_reduction_nest.cpp │ │ ├── kmp_taskloop.c │ │ ├── kmp_taskloop_5.c │ │ ├── nested_parallel_tasking.c │ │ ├── nested_task_creation.c │ │ ├── omp50_task_depend_mtx.c │ │ ├── omp50_task_depend_mtx2.c │ │ ├── omp50_task_depend_mtx3.c │ │ ├── omp50_taskwait_depend.c │ │ ├── omp_detach_taskwait.c │ │ ├── omp_fill_taskqueue.c │ │ ├── omp_task.c │ │ ├── omp_task_depend.c │ │ ├── omp_task_depend_resize_hashmap.c │ │ ├── omp_task_final.c │ │ ├── omp_task_firstprivate.c │ │ ├── omp_task_if.c │ │ ├── omp_task_imp_firstprivate.c │ │ ├── omp_task_nest_tied.c │ │ ├── omp_task_nest_untied.c │ │ ├── omp_task_priority.c │ │ ├── omp_task_private.c │ │ ├── omp_task_red_taskloop.c │ │ ├── omp_task_shared.c │ │ ├── omp_taskloop_grainsize.c │ │ ├── omp_taskloop_num_tasks.c │ │ ├── omp_taskloop_taskwait.c │ │ ├── omp_taskwait.c │ │ ├── omp_taskyield.c │ │ ├── omp_taskyield_tied.c │ │ ├── taskdep_if0.c │ │ └── taskdep_if0_2.c │ ├── teams │ │ └── teams.c │ ├── threadprivate │ │ ├── omp_threadprivate.c │ │ └── omp_threadprivate_for.c │ └── worksharing │ │ ├── for │ │ ├── bug_set_schedule_0.c │ │ ├── kmp_doacross_check.c │ │ ├── kmp_sch_simd_guided.c │ │ ├── kmp_sch_simd_runtime_api.c │ │ ├── kmp_sch_simd_runtime_guided.c │ │ ├── kmp_sch_simd_runtime_static.c │ │ ├── kmp_set_dispatch_buf.c │ │ ├── omp_doacross.c │ │ ├── omp_for_bigbounds.c │ │ ├── omp_for_collapse.c │ │ ├── omp_for_collapse_mini.c │ │ ├── omp_for_firstprivate.c │ │ ├── omp_for_firstprivate_nothreadprivate.c │ │ ├── omp_for_lastprivate.c │ │ ├── omp_for_lastprivate_nothreadprivate.c │ │ ├── omp_for_nowait.c │ │ ├── omp_for_ordered.c │ │ ├── omp_for_private.c │ │ ├── omp_for_private_nothreadprivate.c │ │ ├── omp_for_reduction.c │ │ ├── omp_for_schedule_auto.c │ │ ├── omp_for_schedule_auto_nothreadprivate.c │ │ ├── omp_for_schedule_dynamic.c │ │ ├── omp_for_schedule_guided.c │ │ ├── omp_for_schedule_runtime.c │ │ ├── omp_for_schedule_static.c │ │ ├── omp_for_schedule_static_3.c │ │ ├── omp_monotonic_env.c │ │ ├── omp_monotonic_schedule_set_get.c │ │ ├── omp_nonmonotonic_dynamic1.c │ │ ├── omp_nonmonotonic_nowait.c │ │ ├── omp_parallel_for_firstprivate.c │ │ ├── omp_parallel_for_if.c │ │ ├── omp_parallel_for_lastprivate.c │ │ ├── omp_parallel_for_ordered.c │ │ ├── omp_parallel_for_ordered_nothreadprivate.c │ │ ├── omp_parallel_for_private.c │ │ └── omp_parallel_for_reduction.c │ │ ├── sections │ │ ├── omp_parallel_sections_firstprivate.c │ │ ├── omp_parallel_sections_lastprivate.c │ │ ├── omp_parallel_sections_private.c │ │ ├── omp_parallel_sections_reduction.c │ │ ├── omp_section_firstprivate.c │ │ ├── omp_section_lastprivate.c │ │ ├── omp_section_private.c │ │ ├── omp_sections_nowait.c │ │ └── omp_sections_reduction.c │ │ └── single │ │ ├── omp_single.c │ │ ├── omp_single_copyprivate.c │ │ ├── omp_single_copyprivate_nothreadprivate.c │ │ ├── omp_single_nowait.c │ │ ├── omp_single_private.c │ │ └── omp_single_private_nothreadprivate.c └── tools │ ├── check-depends.pl │ ├── check-execstack.pl │ ├── check-instruction-set.pl │ ├── generate-def.pl │ ├── lib │ ├── Build.pm │ ├── LibOMP.pm │ ├── Platform.pm │ ├── Uname.pm │ └── tools.pm │ ├── message-converter.pl │ └── summarizeStats.py ├── tools ├── CMakeLists.txt ├── analyzer │ ├── analyzer.py │ ├── llvm-openmp-analyzer │ └── llvm-openmp-analyzer++ ├── archer │ ├── CMakeLists.txt │ ├── README.md │ ├── ompt-tsan.cpp │ └── tests │ │ ├── CMakeLists.txt │ │ ├── barrier │ │ └── barrier.c │ │ ├── critical │ │ ├── critical.c │ │ ├── lock-nested.c │ │ └── lock.c │ │ ├── deflake.bash │ │ ├── lit.cfg │ │ ├── lit.site.cfg.in │ │ ├── ompt │ │ └── ompt-signal.h │ │ ├── parallel │ │ ├── parallel-firstprivate.c │ │ ├── parallel-nosuppression.c │ │ ├── parallel-simple.c │ │ └── parallel-simple2.c │ │ ├── races │ │ ├── critical-unrelated.c │ │ ├── lock-nested-unrelated.c │ │ ├── lock-unrelated.c │ │ ├── parallel-simple.c │ │ ├── task-dependency.c │ │ ├── task-taskgroup-unrelated.c │ │ ├── task-taskwait-nested.c │ │ └── task-two.c │ │ ├── reduction │ │ ├── parallel-reduction-nowait.c │ │ └── parallel-reduction.c │ │ ├── task │ │ ├── task-barrier.c │ │ ├── task-create.c │ │ ├── task-dependency.c │ │ ├── task-taskgroup-nested.c │ │ ├── task-taskgroup.c │ │ ├── task-taskwait-nested.c │ │ ├── task-taskwait.c │ │ ├── task_early_fulfill.c │ │ └── task_late_fulfill.c │ │ └── worksharing │ │ └── ordered.c └── multiplex │ ├── CMakeLists.txt │ ├── README.md │ ├── ompt-multiplex.h │ └── tests │ ├── CMakeLists.txt │ ├── custom_data_storage │ ├── custom_data_storage.c │ ├── first-tool.h │ └── second-tool.h │ ├── lit.cfg │ ├── lit.site.cfg.in │ ├── ompt-signal.h │ └── print │ ├── first-tool.h │ ├── print.c │ └── second-tool.h └── www ├── README.txt ├── Reference.pdf ├── content.css ├── index.html └── menu.css /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build-bolt: 11 | 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ ubuntu-latest ] 16 | abt: [ yes, no ] 17 | steps: 18 | - uses: actions/checkout@v2 19 | with: 20 | submodules: 'true' 21 | - name: cmake 22 | run: | 23 | mkdir build 24 | cd build 25 | cmake ../ -DLIBOMP_USE_ARGOBOTS=${{ matrix.abt }} -DOPENMP_ENABLE_WERROR=TRUE 26 | - name: make 27 | run: | 28 | cd build 29 | make -j 2 30 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/argobots"] 2 | path = external/argobots 3 | url = https://github.com/pmodels/argobots 4 | -------------------------------------------------------------------------------- /cmake/config-ix.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlag) 2 | 3 | check_cxx_compiler_flag(-Wall OPENMP_HAVE_WALL_FLAG) 4 | check_cxx_compiler_flag(-Werror OPENMP_HAVE_WERROR_FLAG) 5 | 6 | # Additional warnings that are not enabled by -Wall. 7 | check_cxx_compiler_flag(-Wcast-qual OPENMP_HAVE_WCAST_QUAL_FLAG) 8 | check_cxx_compiler_flag(-Wformat-pedantic OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG) 9 | check_cxx_compiler_flag(-Wimplicit-fallthrough OPENMP_HAVE_WIMPLICIT_FALLTHROUGH_FLAG) 10 | check_cxx_compiler_flag(-Wsign-compare OPENMP_HAVE_WSIGN_COMPARE_FLAG) 11 | 12 | # Warnings that we want to disable because they are too verbose or fragile. 13 | check_cxx_compiler_flag(-Wno-extra OPENMP_HAVE_WNO_EXTRA_FLAG) 14 | check_cxx_compiler_flag(-Wno-pedantic OPENMP_HAVE_WNO_PEDANTIC_FLAG) 15 | check_cxx_compiler_flag(-Wno-maybe-uninitialized OPENMP_HAVE_WNO_MAYBE_UNINITIALIZED_FLAG) 16 | 17 | check_cxx_compiler_flag(-std=gnu++14 OPENMP_HAVE_STD_GNUPP14_FLAG) 18 | check_cxx_compiler_flag(-std=c++14 OPENMP_HAVE_STD_CPP14_FLAG) 19 | -------------------------------------------------------------------------------- /docs/ReleaseNotes.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | openmp 11.0.0 Release Notes 3 | =========================== 4 | 5 | .. contents:: 6 | :local: 7 | 8 | .. warning:: 9 | These are in-progress notes for the upcoming LLVM 11.0.0 release. 10 | Release notes for previous releases can be found on 11 | `the Download Page `_. 12 | 13 | Introduction 14 | ============ 15 | 16 | This document contains the release notes for the OpenMP runtime, release 11.0.0. 17 | Here we describe the status of openmp, including major improvements 18 | from the previous release. All openmp releases may be downloaded 19 | from the `LLVM releases web site `_. 20 | 21 | Non-comprehensive list of changes in this release 22 | ================================================= 23 | 24 | 5.0 features 25 | ------------ 26 | 27 | * ... 28 | 29 | 5.1 features 30 | ------------ 31 | 32 | * ... 33 | 34 | OMPT Improvements 35 | ----------------- 36 | 37 | * Added OMPT callbacks for doacross loops, detached tasks 38 | * Added handling for mutexinoutset dependencies 39 | 40 | OMPT-based Tools 41 | ---------------- 42 | 43 | * Added ompt-multiplex.h as a header-only OMPT-tool to support nesting of OMPT 44 | tools. (see openmp/tools/multiplex) 45 | 46 | -------------------------------------------------------------------------------- /examples/sample_nested.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ 2 | 3 | /* 4 | * See LICENSE.txt in top-level directory. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char *argv[]) { 13 | 14 | int size = (argc > 1) ? atoi(argv[1]) : 100; 15 | int i, j; 16 | int nthreads; 17 | struct timeval t_start, t_end; 18 | double time; 19 | 20 | double *a = (double *)malloc(sizeof(double) * size * size); 21 | 22 | #pragma omp parallel 23 | { nthreads = omp_get_num_threads(); } 24 | 25 | for (i = 0; i < size * size; i++) { 26 | a[i] = i; 27 | } 28 | 29 | gettimeofday(&t_start, NULL); 30 | 31 | #pragma omp parallel for 32 | for (i = 0; i < size; i++) { 33 | #pragma omp parallel for 34 | for (j = 0; j < size; j++) { 35 | a[i * size + j] = a[i * size + j] * 0.9; 36 | } 37 | } 38 | 39 | gettimeofday(&t_end, NULL); 40 | 41 | time = (t_end.tv_sec * 1000000 + t_end.tv_usec) - 42 | (t_start.tv_sec * 1000000 + t_start.tv_usec); 43 | 44 | printf("%d %f\n", nthreads, time / 1000000.0); 45 | 46 | for (i = 0; i < size * size; i++) { 47 | if (a[i] != i * 0.9) { 48 | printf("a[%d]=%f\n", i, a[i]); 49 | return 1; 50 | } 51 | } 52 | free(a); 53 | } 54 | -------------------------------------------------------------------------------- /examples/sample_task_multiple_producer.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ 2 | 3 | /* 4 | * See LICENSE.txt in top-level directory. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char *argv[]) { 13 | 14 | int i, num = (argc > 1) ? atoi(argv[1]) : 100; 15 | int nthreads; 16 | struct timeval t_start, t_end; 17 | double time; 18 | double *a = (double *)malloc(sizeof(double) * num); 19 | 20 | #pragma omp parallel 21 | { nthreads = omp_get_num_threads(); } 22 | 23 | for (i = 0; i < num; i++) { 24 | a[i] = i; 25 | } 26 | 27 | gettimeofday(&t_start, NULL); 28 | 29 | #pragma omp parallel 30 | { 31 | #pragma omp for 32 | for (i = 0; i < num; i++) { 33 | #pragma omp task 34 | { a[i] *= 0.9; } 35 | } 36 | } 37 | 38 | gettimeofday(&t_end, NULL); 39 | 40 | time = (t_end.tv_sec * 1000000 + t_end.tv_usec) - 41 | (t_start.tv_sec * 1000000 + t_start.tv_usec); 42 | 43 | printf("%d %f\n", nthreads, time / 1000000.0); 44 | 45 | for (i = 0; i < num; i++) { 46 | if (a[i] != i * 0.9) { 47 | printf("a[%d]=%f != %f\n", i, a[i], i * 0.9); 48 | return 1; 49 | } 50 | } 51 | free(a); 52 | } 53 | -------------------------------------------------------------------------------- /examples/sample_task_single_producer.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ 2 | 3 | /* 4 | * See LICENSE.txt in top-level directory. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char *argv[]) { 13 | 14 | int i, num = (argc > 1) ? atoi(argv[1]) : 100; 15 | int nthreads; 16 | struct timeval t_start, t_end; 17 | double time; 18 | double *a = (double *)malloc(sizeof(double) * num); 19 | 20 | #pragma omp parallel 21 | { nthreads = omp_get_num_threads(); } 22 | 23 | for (i = 0; i < num; i++) { 24 | a[i] = i; 25 | } 26 | 27 | gettimeofday(&t_start, NULL); 28 | 29 | #pragma omp parallel 30 | { 31 | #pragma omp single 32 | { 33 | for (i = 0; i < num; i++) { 34 | #pragma omp task 35 | { a[i] *= 0.9; } 36 | } 37 | } 38 | } 39 | 40 | gettimeofday(&t_end, NULL); 41 | 42 | time = (t_end.tv_sec * 1000000 + t_end.tv_usec) - 43 | (t_start.tv_sec * 1000000 + t_start.tv_usec); 44 | 45 | printf("%d %f\n", nthreads, time / 1000000.0); 46 | 47 | for (i = 0; i < num; i++) { 48 | if (a[i] != i * 0.9) { 49 | printf("a[%d]=%f != %f\n", i, a[i], i * 0.9); 50 | return 1; 51 | } 52 | } 53 | free(a); 54 | } 55 | -------------------------------------------------------------------------------- /libomptarget/cmake/Modules/LibomptargetUtils.cmake: -------------------------------------------------------------------------------- 1 | # 2 | #//===----------------------------------------------------------------------===// 3 | #// 4 | #// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 | #// See https://llvm.org/LICENSE.txt for license information. 6 | #// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | #// 8 | #//===----------------------------------------------------------------------===// 9 | # 10 | 11 | # void libomptarget_say(string message_to_user); 12 | # - prints out message_to_user 13 | macro(libomptarget_say message_to_user) 14 | message(STATUS "BOLT-LIBOMPTARGET: ${message_to_user}") 15 | endmacro() 16 | 17 | # void libomptarget_warning_say(string message_to_user); 18 | # - prints out message_to_user with a warning 19 | macro(libomptarget_warning_say message_to_user) 20 | message(WARNING "BOLT-LIBOMPTARGET: ${message_to_user}") 21 | endmacro() 22 | 23 | # void libomptarget_error_say(string message_to_user); 24 | # - prints out message_to_user with an error and exits cmake 25 | macro(libomptarget_error_say message_to_user) 26 | message(FATAL_ERROR "BOLT-LIBOMPTARGET: ${message_to_user}") 27 | endmacro() 28 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | # ##===----------------------------------------------------------------------===## 8 | # 9 | # Build a device RTL for each available machine. 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | add_subdirectory(nvptx) 14 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/amdgcn/src/amdgcn_interface.h: -------------------------------------------------------------------------------- 1 | //===--- amdgcn_interface.h - OpenMP interface definitions ------- CUDA -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef _AMDGCN_INTERFACE_H_ 10 | #define _AMDGCN_INTERFACE_H_ 11 | 12 | #include 13 | 14 | #define EXTERN extern "C" __attribute__((device)) 15 | typedef uint64_t __kmpc_impl_lanemask_t; 16 | typedef uint32_t omp_lock_t; /* arbitrary type of the right length */ 17 | 18 | EXTERN uint32_t __kmpc_amdgcn_gpu_num_threads(); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/common/device_environment.h: -------------------------------------------------------------------------------- 1 | //===---- device_environment.h - OpenMP GPU device environment --- CUDA -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Global device environment 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef _OMPTARGET_DEVICE_ENVIRONMENT_H_ 14 | #define _OMPTARGET_DEVICE_ENVIRONMENT_H_ 15 | 16 | #include "target_impl.h" 17 | 18 | struct omptarget_device_environmentTy { 19 | int32_t debug_level; 20 | }; 21 | 22 | extern DEVICE omptarget_device_environmentTy omptarget_device_environment; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/common/src/cancel.cu: -------------------------------------------------------------------------------- 1 | //===------ cancel.cu - NVPTX OpenMP cancel interface ------------ CUDA -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Interface to be used in the implementation of OpenMP cancel. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | #pragma omp declare target 13 | 14 | #include "interface.h" 15 | #include "common/debug.h" 16 | 17 | EXTERN int32_t __kmpc_cancellationpoint(kmp_Ident *loc, int32_t global_tid, 18 | int32_t cancelVal) { 19 | PRINT(LD_IO, "call kmpc_cancellationpoint(cancel val %d)\n", (int)cancelVal); 20 | // disabled 21 | return 0; 22 | } 23 | 24 | EXTERN int32_t __kmpc_cancel(kmp_Ident *loc, int32_t global_tid, 25 | int32_t cancelVal) { 26 | PRINT(LD_IO, "call kmpc_cancel(cancel val %d)\n", (int)cancelVal); 27 | // disabled 28 | return 0; 29 | } 30 | 31 | #pragma omp end declare target 32 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/common/src/critical.cu: -------------------------------------------------------------------------------- 1 | //===------ critical.cu - NVPTX OpenMP critical ------------------ CUDA -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // This file contains the implementation of critical with KMPC interface 10 | // 11 | //===----------------------------------------------------------------------===// 12 | #pragma omp declare target 13 | 14 | #include "interface.h" 15 | #include "common/debug.h" 16 | 17 | EXTERN 18 | void __kmpc_critical(kmp_Ident *loc, int32_t global_tid, 19 | kmp_CriticalName *lck) { 20 | PRINT0(LD_IO, "call to kmpc_critical()\n"); 21 | omp_set_lock((omp_lock_t *)lck); 22 | } 23 | 24 | EXTERN 25 | void __kmpc_end_critical(kmp_Ident *loc, int32_t global_tid, 26 | kmp_CriticalName *lck) { 27 | PRINT0(LD_IO, "call to kmpc_end_critical()\n"); 28 | omp_unset_lock((omp_lock_t *)lck); 29 | } 30 | 31 | #pragma omp end declare target 32 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h: -------------------------------------------------------------------------------- 1 | //===--- nvptx_interface.h - OpenMP interface definitions -------- CUDA -*-===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef _NVPTX_INTERFACE_H_ 10 | #define _NVPTX_INTERFACE_H_ 11 | 12 | #include 13 | 14 | #define EXTERN extern "C" __device__ 15 | typedef uint32_t __kmpc_impl_lanemask_t; 16 | typedef uint32_t omp_lock_t; /* arbitrary type of the right length */ 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT OPENMP_TEST_COMPILER_ID STREQUAL "Clang") 2 | # Silently return, no need to annoy the user. 3 | return() 4 | endif() 5 | 6 | set(deps bolt-omptarget bolt-omp) 7 | if(LIBOMPTARGET_NVPTX_ENABLE_BCLIB) 8 | set(deps ${deps} bolt-omptarget-nvptx-bc) 9 | endif() 10 | 11 | # Run with only one thread to only launch one application to the GPU at a time. 12 | add_openmp_testsuite(check-bolt-libomptarget-nvptx 13 | "Running libomptarget-nvptx tests" ${CMAKE_CURRENT_BINARY_DIR} 14 | EXCLUDE_FROM_CHECK_ALL 15 | DEPENDS ${deps} ARGS -j1) 16 | 17 | set(LIBOMPTARGET_NVPTX_TEST_FLAGS "" CACHE STRING 18 | "Extra compiler flags to send to the test compiler.") 19 | set(LIBOMPTARGET_NVPTX_TEST_OPENMP_FLAGS 20 | "-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda" CACHE STRING 21 | "OpenMP compiler flags to use for testing libomptarget-nvptx.") 22 | 23 | # Configure the lit.site.cfg.in file 24 | set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget-nvptx configuration.\n# Do not edit!") 25 | configure_file(lit.site.cfg.in lit.site.cfg @ONLY) 26 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/api/get_max_threads.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | #include 3 | #include 4 | 5 | int main(){ 6 | int max_threads = -1; 7 | int num_threads = -1; 8 | 9 | #pragma omp target map(tofrom: max_threads) 10 | max_threads = omp_get_max_threads(); 11 | 12 | #pragma omp target parallel map(tofrom: num_threads) 13 | { 14 | #pragma omp master 15 | num_threads = omp_get_num_threads(); 16 | } 17 | 18 | // CHECK: Max Threads: 128, Num Threads: 128 19 | printf("Max Threads: %d, Num Threads: %d\n", max_threads, num_threads); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/api/ignored.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | 3 | #include 4 | #include 5 | 6 | const int MaxThreads = 1024; 7 | 8 | int main(int argc, char *argv[]) { 9 | int cancellation = -1, dynamic = -1, nested = -1, maxActiveLevels = -1; 10 | 11 | #pragma omp target map(cancellation, dynamic, nested, maxActiveLevels) 12 | { 13 | // libomptarget-nvptx doesn't support cancellation. 14 | cancellation = omp_get_cancellation(); 15 | 16 | // No support for dynamic adjustment of the number of threads. 17 | omp_set_dynamic(1); 18 | dynamic = omp_get_dynamic(); 19 | 20 | // libomptarget-nvptx doesn't support nested parallelism. 21 | omp_set_nested(1); 22 | nested = omp_get_nested(); 23 | 24 | omp_set_max_active_levels(42); 25 | maxActiveLevels = omp_get_max_active_levels(); 26 | } 27 | 28 | // CHECK: cancellation = 0 29 | printf("cancellation = %d\n", cancellation); 30 | // CHECK: dynamic = 0 31 | printf("dynamic = %d\n", dynamic); 32 | // CHECK: nested = 0 33 | printf("nested = %d\n", nested); 34 | // CHECK: maxActiveLevels = 1 35 | printf("maxActiveLevels = %d\n", maxActiveLevels); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/data_sharing/alignment.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | 3 | #include 4 | #include 5 | 6 | #pragma omp declare target 7 | static void putValueInParallel(int *ptr, int value) { 8 | #pragma omp parallel 9 | { 10 | *ptr = value; 11 | } 12 | } 13 | 14 | static int getId() { 15 | int id; 16 | putValueInParallel(&id, omp_get_thread_num()); 17 | return id; 18 | } 19 | #pragma omp end declare target 20 | 21 | const int MaxThreads = 1024; 22 | const int Threads = 64; 23 | 24 | int main(int argc, char *argv[]) { 25 | int master; 26 | int check[MaxThreads]; 27 | for (int i = 0; i < MaxThreads; i++) { 28 | check[i] = 0; 29 | } 30 | 31 | #pragma omp target map(master, check[:]) 32 | { 33 | master = getId(); 34 | 35 | #pragma omp parallel num_threads(Threads) 36 | { 37 | check[omp_get_thread_num()] = getId(); 38 | } 39 | } 40 | 41 | // CHECK: master = 0. 42 | printf("master = %d.\n", master); 43 | // CHECK-NOT: invalid 44 | for (int i = 0; i < MaxThreads; i++) { 45 | if (i < Threads) { 46 | if (check[i] != i) { 47 | printf("invalid: check[%d] should be %d, is %d\n", i, i, check[i]); 48 | } 49 | } else if (check[i] != 0) { 50 | printf("invalid: check[%d] should be 0, is %d\n", i, check[i]); 51 | } 52 | } 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @AUTO_GEN_COMMENT@ 2 | 3 | config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" 4 | config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" 5 | config.test_openmp_flags = "@LIBOMPTARGET_NVPTX_TEST_OPENMP_FLAGS@" 6 | config.test_extra_flags = "@LIBOMPTARGET_NVPTX_TEST_FLAGS@" 7 | config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" 8 | config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@" 9 | config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@" 10 | config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@" 11 | config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" 12 | config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@" 13 | 14 | # Let the main config do the real work. 15 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") 16 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/parallel/barrier.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) { 7 | int data, out, flag = 0; 8 | #pragma omp target teams num_teams(2) map(tofrom \ 9 | : out) map(to \ 10 | : data, flag) \ 11 | thread_limit(1) 12 | #pragma omp parallel num_threads(1) 13 | { 14 | if (omp_get_team_num() == 0) { 15 | /* Write to the data buffer that will be read by thread in team 1 */ 16 | data = 42; 17 | /* Flush data to thread in team 1 */ 18 | #pragma omp barrier 19 | /* Set flag to release thread in team 1 */ 20 | #pragma omp atomic write 21 | flag = 1; 22 | } else if (omp_get_team_num() == 1) { 23 | /* Loop until we see the update to the flag */ 24 | int val; 25 | do { 26 | #pragma omp atomic read 27 | val = flag; 28 | } while (val < 1); 29 | out = data; 30 | #pragma omp barrier 31 | } 32 | } 33 | // CHECK: out=42. 34 | /* Value of out will be 42 */ 35 | printf("out=%d.\n", out); 36 | return !(out == 42); 37 | } 38 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/parallel/flush.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) { 7 | int data, out, flag = 0; 8 | #pragma omp target parallel num_threads(64) map(tofrom \ 9 | : out, flag) map(to \ 10 | : data) 11 | { 12 | if (omp_get_thread_num() == 0) { 13 | /* Write to the data buffer that will be read by thread */ 14 | data = 42; 15 | /* Flush data to thread 32 */ 16 | #pragma omp flush(data) 17 | /* Set flag to release thread 32 */ 18 | #pragma omp atomic write 19 | flag = 1; 20 | } else if (omp_get_thread_num() == 32) { 21 | /* Loop until we see the update to the flag */ 22 | int val; 23 | do { 24 | #pragma omp atomic read 25 | val = flag; 26 | } while (val < 1); 27 | out = data; 28 | #pragma omp flush(out) 29 | } 30 | } 31 | // CHECK: out=42. 32 | /* Value of out will be 42 */ 33 | printf("out=%d.\n", out); 34 | return !(out == 42); 35 | } 36 | -------------------------------------------------------------------------------- /libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c: -------------------------------------------------------------------------------- 1 | // RUN: %compile-run-and-check 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | int res = 0; 8 | 9 | #pragma omp parallel num_threads(2) reduction(+:res) 10 | { 11 | int tid = omp_get_thread_num(); 12 | #pragma omp target teams distribute reduction(+:res) 13 | for (int i = tid; i < 2; i++) 14 | ++res; 15 | } 16 | // The first thread makes 2 iterations, the second - 1. Expected result of the 17 | // reduction res is 3. 18 | 19 | // CHECK: res = 3. 20 | printf("res = %d.\n", res); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /libomptarget/plugins/aarch64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Build a plugin for an aarch64 machine if available. 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") 14 | build_generic_elf64("aarch64" "aarch64" "aarch64" "aarch64-unknown-linux-gnu" "183") 15 | else() 16 | libomptarget_say("Not building aarch64 offloading plugin: machine not found in the system.") 17 | endif() 18 | -------------------------------------------------------------------------------- /libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_ELF_MACH_GFX_NAME_H_INCLUDED 2 | #define GET_ELF_MACH_GFX_NAME_H_INCLUDED 3 | 4 | #include 5 | 6 | const char *get_elf_mach_gfx_name(uint32_t EFlags); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libomptarget/plugins/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Common parts which can be used by all plugins 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | add_subdirectory(elf_common) 14 | add_subdirectory(MemoryManager) 15 | -------------------------------------------------------------------------------- /libomptarget/plugins/common/MemoryManager/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | 9 | add_library(MemoryManager INTERFACE) 10 | 11 | target_include_directories(MemoryManager INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | -------------------------------------------------------------------------------- /libomptarget/plugins/common/elf_common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Common ELF functionality for target plugins 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | add_library(elf_common INTERFACE) 14 | 15 | target_include_directories(elf_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 16 | -------------------------------------------------------------------------------- /libomptarget/plugins/exports: -------------------------------------------------------------------------------- 1 | VERS1.0 { 2 | global: 3 | __tgt_rtl_is_valid_binary; 4 | __tgt_rtl_is_data_exchangable; 5 | __tgt_rtl_number_of_devices; 6 | __tgt_rtl_init_requires; 7 | __tgt_rtl_init_device; 8 | __tgt_rtl_load_binary; 9 | __tgt_rtl_data_alloc; 10 | __tgt_rtl_data_submit; 11 | __tgt_rtl_data_submit_async; 12 | __tgt_rtl_data_retrieve; 13 | __tgt_rtl_data_retrieve_async; 14 | __tgt_rtl_data_exchange; 15 | __tgt_rtl_data_exchange_async; 16 | __tgt_rtl_data_delete; 17 | __tgt_rtl_run_target_team_region; 18 | __tgt_rtl_run_target_team_region_async; 19 | __tgt_rtl_run_target_region; 20 | __tgt_rtl_run_target_region_async; 21 | __tgt_rtl_synchronize; 22 | local: 23 | *; 24 | }; 25 | -------------------------------------------------------------------------------- /libomptarget/plugins/ppc64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Build a plugin for a ppc64 machine if available. 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") 14 | build_generic_elf64("ppc64" "PPC64" "ppc64" "powerpc64-ibm-linux-gnu" "21") 15 | else() 16 | libomptarget_say("Not building ppc64 offloading plugin: machine not found in the system.") 17 | endif() -------------------------------------------------------------------------------- /libomptarget/plugins/ppc64le/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Build a plugin for a ppc64le machine if available. 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") 14 | build_generic_elf64("ppc64le" "PPC64le" "ppc64" "powerpc64le-ibm-linux-gnu" "21") 15 | else() 16 | libomptarget_say("Not building ppc64le offloading plugin: machine not found in the system.") 17 | endif() -------------------------------------------------------------------------------- /libomptarget/plugins/x86_64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##===----------------------------------------------------------------------===## 2 | # 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | # See https://llvm.org/LICENSE.txt for license information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | # 7 | ##===----------------------------------------------------------------------===## 8 | # 9 | # Build a plugin for a x86_64 machine if available. 10 | # 11 | ##===----------------------------------------------------------------------===## 12 | 13 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") 14 | build_generic_elf64("x86_64" "x86_64" "x86_64" "x86_64-pc-linux-gnu" "62") 15 | else() 16 | libomptarget_say("Not building x86_64 offloading plugin: machine not found in the system.") 17 | endif() -------------------------------------------------------------------------------- /libomptarget/src/exports: -------------------------------------------------------------------------------- 1 | VERS1.0 { 2 | global: 3 | __tgt_register_requires; 4 | __tgt_register_lib; 5 | __tgt_unregister_lib; 6 | __tgt_target_data_begin; 7 | __tgt_target_data_end; 8 | __tgt_target_data_update; 9 | __tgt_target; 10 | __tgt_target_teams; 11 | __tgt_target_data_begin_nowait; 12 | __tgt_target_data_end_nowait; 13 | __tgt_target_data_update_nowait; 14 | __tgt_target_nowait; 15 | __tgt_target_teams_nowait; 16 | __tgt_target_data_begin_mapper; 17 | __tgt_target_data_end_mapper; 18 | __tgt_target_data_update_mapper; 19 | __tgt_target_mapper; 20 | __tgt_target_teams_mapper; 21 | __tgt_target_data_begin_nowait_mapper; 22 | __tgt_target_data_end_nowait_mapper; 23 | __tgt_target_data_update_nowait_mapper; 24 | __tgt_target_nowait_mapper; 25 | __tgt_target_teams_nowait_mapper; 26 | __tgt_mapper_num_components; 27 | __tgt_push_mapper_component; 28 | omp_get_num_devices; 29 | omp_get_initial_device; 30 | omp_target_alloc; 31 | omp_target_free; 32 | omp_target_is_present; 33 | omp_target_memcpy; 34 | omp_target_memcpy_rect; 35 | omp_target_associate_ptr; 36 | omp_target_disassociate_ptr; 37 | __kmpc_push_target_tripcount; 38 | local: 39 | *; 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /libomptarget/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeLists.txt file for unit testing OpenMP offloading runtime library. 2 | if(NOT OPENMP_TEST_COMPILER_ID STREQUAL "Clang" OR 3 | OPENMP_TEST_COMPILER_VERSION VERSION_LESS 6.0.0) 4 | libomptarget_say("Can only test with Clang compiler in version 6.0.0 or later.") 5 | libomptarget_warning_say("The check-libomptarget target will not be available!") 6 | return() 7 | endif() 8 | 9 | if(LIBOMPTARGET_ENABLE_DEBUG) 10 | set(LIBOMPTARGET_DEBUG True) 11 | else() 12 | set(LIBOMPTARGET_DEBUG False) 13 | endif() 14 | 15 | add_openmp_testsuite(check-bolt-libomptarget "Running libomptarget tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS bolt-omptarget bolt-omp ${LIBBOLTTARGET_TESTED_PLUGINS}) 16 | 17 | # Configure the lit.site.cfg.in file 18 | set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!") 19 | configure_file(lit.site.cfg.in lit.site.cfg @ONLY) 20 | -------------------------------------------------------------------------------- /libomptarget/test/api/omp_get_num_devices.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | 6 | #include 7 | #include 8 | 9 | int test_omp_get_num_devices() 10 | { 11 | /* checks that omp_get_num_devices() > 0 */ 12 | int num_devices = omp_get_num_devices(); 13 | printf("num_devices = %d\n", num_devices); 14 | 15 | #pragma omp target 16 | {} 17 | 18 | return (num_devices > 0); 19 | } 20 | 21 | int main() 22 | { 23 | int i; 24 | int failed=0; 25 | 26 | if (!test_omp_get_num_devices()) { 27 | failed++; 28 | } 29 | if (failed) 30 | printf("FAIL\n"); 31 | else 32 | printf("PASS\n"); 33 | return failed; 34 | } 35 | 36 | // CHECK: PASS 37 | -------------------------------------------------------------------------------- /libomptarget/test/api/omp_get_num_devices_with_empty_target.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | 6 | #include 7 | #include 8 | 9 | static int test_omp_get_num_devices_with_empty_target() { 10 | /* checks that omp_get_num_devices() > 0 */ 11 | return omp_get_num_devices() > 0; 12 | } 13 | 14 | int main() { 15 | int failed = 0; 16 | 17 | if (!test_omp_get_num_devices_with_empty_target()) { 18 | ++failed; 19 | } 20 | 21 | if (failed) { 22 | printf("FAIL\n"); 23 | } else { 24 | printf("PASS\n"); 25 | } 26 | 27 | return failed; 28 | } 29 | 30 | // CHECK: PASS 31 | -------------------------------------------------------------------------------- /libomptarget/test/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @AUTO_GEN_COMMENT@ 2 | 3 | config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" 4 | config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" 5 | config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ 6 | config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" 7 | config.test_extra_flags = "@OPENMP_TEST_FLAGS@" 8 | config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" 9 | config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@" 10 | config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@" 11 | config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@" 12 | config.operating_system = "@CMAKE_SYSTEM_NAME@" 13 | config.libomptarget_all_targets = "@LIBOMPTARGET_ALL_TARGETS@".split() 14 | config.libomptarget_system_targets = "@LIBBOLTTARGET_SYSTEM_TARGETS@".split() 15 | config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" 16 | config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@" 17 | config.libomptarget_debug = @LIBOMPTARGET_DEBUG@ 18 | 19 | # Let the main config do the real work. 20 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") 21 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/declare_mapper_target.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | #define NUM 1024 11 | 12 | class C { 13 | public: 14 | int *a; 15 | }; 16 | 17 | #pragma omp declare mapper(id: C s) map(s.a[0:NUM]) 18 | 19 | int main() { 20 | C c; 21 | c.a = (int*) malloc(sizeof(int)*NUM); 22 | for (int i = 0; i < NUM; i++) { 23 | c.a[i] = 1; 24 | } 25 | #pragma omp target teams distribute parallel for map(mapper(id),tofrom: c) 26 | for (int i = 0; i < NUM; i++) { 27 | ++c.a[i]; 28 | } 29 | int sum = 0; 30 | for (int i = 0; i < NUM; i++) { 31 | sum += c.a[i]; 32 | } 33 | // CHECK: Sum = 2048 34 | printf("Sum = %d\n", sum); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/declare_mapper_target_data.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | #define NUM 1024 11 | 12 | class C { 13 | public: 14 | int *a; 15 | }; 16 | 17 | #pragma omp declare mapper(id: C s) map(s.a[0:NUM]) 18 | 19 | int main() { 20 | C c; 21 | c.a = (int*) malloc(sizeof(int)*NUM); 22 | for (int i = 0; i < NUM; i++) { 23 | c.a[i] = 1; 24 | } 25 | #pragma omp target data map(mapper(id),tofrom: c) 26 | { 27 | #pragma omp target teams distribute parallel for 28 | for (int i = 0; i < NUM; i++) { 29 | ++c.a[i]; 30 | } 31 | } 32 | int sum = 0; 33 | for (int i = 0; i < NUM; i++) { 34 | sum += c.a[i]; 35 | } 36 | // CHECK: Sum = 2048 37 | printf("Sum = %d\n", sum); 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/declare_mapper_target_data_enter_exit.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | #define NUM 1024 11 | 12 | class C { 13 | public: 14 | int *a; 15 | }; 16 | 17 | #pragma omp declare mapper(id: C s) map(s.a[0:NUM]) 18 | 19 | int main() { 20 | C c; 21 | c.a = (int*) malloc(sizeof(int)*NUM); 22 | for (int i = 0; i < NUM; i++) { 23 | c.a[i] = 1; 24 | } 25 | #pragma omp target enter data map(mapper(id),to: c) 26 | #pragma omp target teams distribute parallel for 27 | for (int i = 0; i < NUM; i++) { 28 | ++c.a[i]; 29 | } 30 | #pragma omp target exit data map(mapper(id),from: c) 31 | int sum = 0; 32 | for (int i = 0; i < NUM; i++) { 33 | sum += c.a[i]; 34 | } 35 | // CHECK: Sum = 2048 36 | printf("Sum = %d\n", sum); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/delete_inf_refcount.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | #pragma omp declare target 11 | int isHost; 12 | #pragma omp end declare target 13 | 14 | int main(void) { 15 | isHost = -1; 16 | 17 | #pragma omp target enter data map(to: isHost) 18 | 19 | #pragma omp target 20 | { isHost = omp_is_initial_device(); } 21 | #pragma omp target update from(isHost) 22 | 23 | if (isHost < 0) { 24 | printf("Runtime error, isHost=%d\n", isHost); 25 | } 26 | 27 | #pragma omp target exit data map(delete: isHost) 28 | 29 | // CHECK: Target region executed on the device 30 | printf("Target region executed on the %s\n", isHost ? "host" : "device"); 31 | 32 | return isHost; 33 | } 34 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/present/target_data_at_exit.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 2 | // RUN: %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 \ 3 | // RUN: | %fcheck-aarch64-unknown-linux-gnu 4 | 5 | // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 6 | // RUN: %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 \ 7 | // RUN: | %fcheck-powerpc64-ibm-linux-gnu 8 | 9 | // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 10 | // RUN: %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 \ 11 | // RUN: | %fcheck-powerpc64le-ibm-linux-gnu 12 | 13 | // RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 14 | // RUN: %libomptarget-run-x86_64-pc-linux-gnu 2>&1 \ 15 | // RUN: | %fcheck-x86_64-pc-linux-gnu 16 | 17 | #include 18 | 19 | int main() { 20 | int i; 21 | 22 | #pragma omp target enter data map(alloc:i) 23 | 24 | // i isn't present at the end of the target data region, but the "present" 25 | // modifier is only checked at the beginning of a region. 26 | #pragma omp target data map(present, alloc: i) 27 | { 28 | #pragma omp target exit data map(delete:i) 29 | } 30 | 31 | // CHECK-NOT: Libomptarget 32 | // CHECK: success 33 | // CHECK-NOT: Libomptarget 34 | fprintf(stderr, "success\n"); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/present/unified_shared_memory.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51 2 | // RUN: %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 \ 3 | // RUN: | %fcheck-aarch64-unknown-linux-gnu 4 | 5 | // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51 6 | // RUN: %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 \ 7 | // RUN: | %fcheck-powerpc64-ibm-linux-gnu 8 | 9 | // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51 10 | // RUN: %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 \ 11 | // RUN: | %fcheck-powerpc64le-ibm-linux-gnu 12 | 13 | // RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51 14 | // RUN: %libomptarget-run-x86_64-pc-linux-gnu 2>&1 \ 15 | // RUN: | %fcheck-x86_64-pc-linux-gnu 16 | 17 | #include 18 | 19 | // The runtime considers unified shared memory to be always present. 20 | #pragma omp requires unified_shared_memory 21 | 22 | int main() { 23 | int i; 24 | 25 | // CHECK-NOT: Libomptarget 26 | #pragma omp target data map(alloc: i) 27 | #pragma omp target map(present, alloc: i) 28 | ; 29 | 30 | // CHECK: i is present 31 | fprintf(stderr, "i is present\n"); 32 | 33 | // CHECK-NOT: Libomptarget 34 | #pragma omp target map(present, alloc: i) 35 | ; 36 | 37 | // CHECK: is present 38 | fprintf(stderr, "i is present\n"); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/private_mapping.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | int main() { 11 | int data1[3] = {1}, data2[3] = {2}, data3[3] = {3}; 12 | int sum[16] = {0}; 13 | #pragma omp target teams distribute parallel for map(tofrom \ 14 | : sum) \ 15 | firstprivate(data1, data2, data3) 16 | for (int i = 0; i < 16; ++i) { 17 | for (int j = 0; j < 3; ++j) { 18 | sum[i] += data1[j]; 19 | sum[i] += data2[j]; 20 | sum[i] += data3[j]; 21 | } 22 | } 23 | 24 | for (int i = 0; i < 16; ++i) { 25 | assert(sum[i] == 6); 26 | } 27 | 28 | printf("PASS\n"); 29 | 30 | return 0; 31 | } 32 | 33 | // CHECK: PASS 34 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/ptr_and_obj_motion.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | 9 | typedef struct { 10 | double *dataptr; 11 | int dummy1; 12 | int dummy2; 13 | } DV; 14 | 15 | void init(double vertexx[]) { 16 | #pragma omp target map(vertexx[0:100]) 17 | { 18 | printf("In init: %lf, expected 100.0\n", vertexx[77]); 19 | vertexx[77] = 77.0; 20 | } 21 | } 22 | 23 | void change(DV *dvptr) { 24 | #pragma omp target map(dvptr->dataptr[0:100]) 25 | { 26 | printf("In change: %lf, expected 77.0\n", dvptr->dataptr[77]); 27 | dvptr->dataptr[77] += 1.0; 28 | } 29 | } 30 | 31 | int main() { 32 | double vertexx[100]; 33 | vertexx[77] = 100.0; 34 | 35 | DV dv; 36 | dv.dataptr = &vertexx[0]; 37 | 38 | #pragma omp target enter data map(to:vertexx[0:100]) 39 | 40 | init(vertexx); 41 | change(&dv); 42 | 43 | #pragma omp target exit data map(from:vertexx[0:100]) 44 | 45 | // CHECK: Final: 78.0 46 | printf("Final: %lf\n", vertexx[77]); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /libomptarget/test/mapping/target_implicit_partial_map.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 \ 3 | // RUN: | %fcheck-aarch64-unknown-linux-gnu 4 | 5 | // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu 6 | // RUN: %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 \ 7 | // RUN: | %fcheck-powerpc64-ibm-linux-gnu 8 | 9 | // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu 10 | // RUN: %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 \ 11 | // RUN: | %fcheck-powerpc64le-ibm-linux-gnu 12 | 13 | // RUN: %libomptarget-compile-x86_64-pc-linux-gnu 14 | // RUN: %libomptarget-run-x86_64-pc-linux-gnu 2>&1 \ 15 | // RUN: | %fcheck-x86_64-pc-linux-gnu 16 | // 17 | // END. 18 | 19 | #include 20 | #include 21 | 22 | int main() { 23 | int arr[100]; 24 | 25 | #pragma omp target data map(alloc: arr[50:2]) // partially mapped 26 | { 27 | #pragma omp target // would implicitly map with full size but already present 28 | { 29 | arr[50] = 5; 30 | arr[51] = 6; 31 | } // must treat as present (dec ref count) even though full size not present 32 | } // wouldn't delete if previous ref count dec didn't happen 33 | 34 | // CHECK: still present: 0 35 | fprintf(stderr, "still present: %d\n", 36 | omp_target_is_present(&arr[50], omp_get_default_device())); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /libomptarget/test/offloading/bug47654.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) { 11 | int i = 0, j = 0; 12 | 13 | #pragma omp target map(tofrom : i, j) nowait 14 | { 15 | i = 1; 16 | j = 2; 17 | } 18 | 19 | #pragma omp taskwait 20 | 21 | assert(i == 1); 22 | assert(j == 2); 23 | 24 | std::cout << "PASS\n"; 25 | 26 | return 0; 27 | } 28 | 29 | // CHECK: PASS 30 | -------------------------------------------------------------------------------- /libomptarget/test/offloading/dynamic_module.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -DSHARED -fPIC -shared -o %t.so && %libomptarget-compile-aarch64-unknown-linux-gnu %t.so && %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 | %fcheck-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -DSHARED -fPIC -shared -o %t.so && %libomptarget-compile-powerpc64-ibm-linux-gnu %t.so && %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 | %fcheck-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -DSHARED -fPIC -shared -o %t.so && %libomptarget-compile-powerpc64le-ibm-linux-gnu %t.so && %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 | %fcheck-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-x86_64-pc-linux-gnu -DSHARED -fPIC -shared -o %t.so && %libomptarget-compile-x86_64-pc-linux-gnu %t.so && %libomptarget-run-x86_64-pc-linux-gnu 2>&1 | %fcheck-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-nvptx64-nvidia-cuda -DSHARED -fPIC -shared -o %t.so && %libomptarget-compile-nvptx64-nvidia-cuda %t.so && %libomptarget-run-nvptx64-nvidia-cuda 2>&1 | %fcheck-nvptx64-nvidia-cuda 6 | 7 | #ifdef SHARED 8 | void foo() {} 9 | #else 10 | #include 11 | int main() { 12 | #pragma omp target 13 | ; 14 | // CHECK: DONE. 15 | printf("%s\n", "DONE."); 16 | return 0; 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /libomptarget/test/offloading/offloading_success.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compile-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compile-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compile-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | int main(void) { 11 | int isHost = -1; 12 | 13 | #pragma omp target map(from: isHost) 14 | { isHost = omp_is_initial_device(); } 15 | 16 | if (isHost < 0) { 17 | printf("Runtime error, isHost=%d\n", isHost); 18 | } 19 | 20 | // CHECK: Target region executed on the device 21 | printf("Target region executed on the %s\n", isHost ? "host" : "device"); 22 | 23 | return isHost; 24 | } 25 | -------------------------------------------------------------------------------- /libomptarget/test/offloading/offloading_success.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | int main(void) { 11 | int isHost = 0; 12 | 13 | #pragma omp target map(from: isHost) 14 | { isHost = omp_is_initial_device(); } 15 | 16 | if (isHost < 0) { 17 | printf("Runtime error, isHost=%d\n", isHost); 18 | } 19 | 20 | // CHECK: Target region executed on the device 21 | printf("Target region executed on the %s\n", isHost ? "host" : "device"); 22 | 23 | return isHost; 24 | } 25 | -------------------------------------------------------------------------------- /libomptarget/test/offloading/parallel_offloading_map.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu 2 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu 3 | // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu 4 | // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu 5 | // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) { 11 | constexpr const int num_threads = 8, N = 16; 12 | int array[num_threads] = {0}; 13 | 14 | #pragma omp parallel for 15 | for (int i = 0; i < num_threads; ++i) { 16 | int tmp[N]; 17 | 18 | for (int j = 0; j < N; ++j) { 19 | tmp[j] = i; 20 | } 21 | 22 | #pragma omp target teams distribute parallel for map(tofrom : tmp) 23 | for (int j = 0; j < N; ++j) { 24 | tmp[j] += j; 25 | } 26 | 27 | for (int j = 0; j < N; ++j) { 28 | array[i] += tmp[j]; 29 | } 30 | } 31 | 32 | // Verify 33 | for (int i = 0; i < num_threads; ++i) { 34 | const int ref = (0 + N - 1) * N / 2 + i * N; 35 | assert(array[i] == ref); 36 | } 37 | 38 | std::cout << "PASS\n"; 39 | 40 | return 0; 41 | } 42 | 43 | // CHECK: PASS 44 | -------------------------------------------------------------------------------- /runtime/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | AlignTrailingComments: false 4 | SortIncludes: false 5 | ... 6 | -------------------------------------------------------------------------------- /runtime/cmake/LibboltSymlinkArgobots.cmake: -------------------------------------------------------------------------------- 1 | # Create symbolic links for testing. 2 | 3 | FILE(GLOB LIBOMP_ARGOBOTS_LIBS "${LIBOMP_ARGOBOTS_INSTALL_DIR}/lib/${SHARED_LIBRARY_PREFIX}*${SHARED_LIBRARY_SUFFIX}*") 4 | foreach(LIBOMP_ARGOBOTS_LIB IN LISTS LIBOMP_ARGOBOTS_LIBS) 5 | get_filename_component(LIBOMP_ARGOBOTS_LIB_NAME "${LIBOMP_ARGOBOTS_LIB}" NAME) 6 | execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LIBOMP_ARGOBOTS_LIB}" "${LIBOMP_ARGOBOTS_LIB_NAME}" 7 | WORKING_DIRECTORY ${LIBBOLT_LIBRARY_DIR} 8 | ) 9 | endforeach() 10 | execute_process( 11 | COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBOMP_ARGOBOTS_INSTALL_DIR}/include/abt.h abt.h 12 | WORKING_DIRECTORY ${LIBBOLT_INCLUDE_DIR} 13 | ) 14 | -------------------------------------------------------------------------------- /runtime/cmake/LibompCheckFortranFlag.cmake: -------------------------------------------------------------------------------- 1 | # 2 | #//===----------------------------------------------------------------------===// 3 | #// 4 | #// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 | #// See https://llvm.org/LICENSE.txt for license information. 6 | #// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | #// 8 | #//===----------------------------------------------------------------------===// 9 | # 10 | 11 | # Checking a fortran compiler flag 12 | # There is no real trivial way to do this in CMake, so we implement it here 13 | # this will have ${boolean} = TRUE if the flag succeeds, otherwise false. 14 | function(libomp_check_fortran_flag flag boolean) 15 | if(NOT DEFINED "${boolean}") 16 | set(retval TRUE) 17 | set(fortran_source 18 | " program hello 19 | print *, \"Hello World!\" 20 | end program hello") 21 | 22 | set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping") 23 | include(CheckFortranSourceCompiles) 24 | check_fortran_source_compiles("${fortran_source}" ${boolean} FAIL_REGEX "${failed_regexes}") 25 | set(${boolean} ${${boolean}} PARENT_SCOPE) 26 | endif() 27 | endfunction() 28 | -------------------------------------------------------------------------------- /runtime/cmake/LibompDefinitions.cmake: -------------------------------------------------------------------------------- 1 | # 2 | #//===----------------------------------------------------------------------===// 3 | #// 4 | #// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 | #// See https://llvm.org/LICENSE.txt for license information. 6 | #// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 | #// 8 | #//===----------------------------------------------------------------------===// 9 | # 10 | 11 | function(libomp_get_definitions_flags cppflags) 12 | set(cppflags_local) 13 | 14 | if(WIN32) 15 | libomp_append(cppflags_local "-D _CRT_SECURE_NO_WARNINGS") 16 | libomp_append(cppflags_local "-D _CRT_SECURE_NO_DEPRECATE") 17 | libomp_append(cppflags_local "-D _WINDOWS") 18 | libomp_append(cppflags_local "-D _WINNT") 19 | libomp_append(cppflags_local "-D _WIN32_WINNT=0x0501") 20 | libomp_append(cppflags_local "-D _USRDLL") 21 | libomp_append(cppflags_local "-D _ITERATOR_DEBUG_LEVEL=0" IF_TRUE DEBUG_BUILD) 22 | libomp_append(cppflags_local "-D _DEBUG" IF_TRUE DEBUG_BUILD) 23 | else() 24 | libomp_append(cppflags_local "-D _GNU_SOURCE") 25 | libomp_append(cppflags_local "-D _REENTRANT") 26 | endif() 27 | 28 | # CMake doesn't include CPPFLAGS from environment, but we will. 29 | set(${cppflags} ${cppflags_local} ${LIBOMP_CPPFLAGS} $ENV{CPPFLAGS} PARENT_SCOPE) 30 | endfunction() 31 | -------------------------------------------------------------------------------- /runtime/doc/Reference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmodels/bolt/c1dc0e6e6ff6355319efa8f6c1dde7f02031afbf/runtime/doc/Reference.pdf -------------------------------------------------------------------------------- /runtime/src/kmp_ftn_cdecl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * kmp_ftn_cdecl.cpp -- Fortran __cdecl linkage support for OpenMP. 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // See https://llvm.org/LICENSE.txt for license information. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "kmp.h" 14 | #include "kmp_affinity.h" 15 | 16 | #if KMP_OS_WINDOWS 17 | #if defined KMP_WIN_CDECL || !KMP_DYNAMIC_LIB 18 | #define KMP_FTN_ENTRIES KMP_FTN_UPPER 19 | #endif 20 | #elif KMP_OS_UNIX 21 | #define KMP_FTN_ENTRIES KMP_FTN_PLAIN 22 | #endif 23 | 24 | // Note: This string is not printed when KMP_VERSION=1. 25 | char const __kmp_version_ftncdecl[] = 26 | KMP_VERSION_PREFIX "Fortran __cdecl OMP support: " 27 | #ifdef KMP_FTN_ENTRIES 28 | "yes"; 29 | #define FTN_STDCALL /* no stdcall */ 30 | #include "kmp_ftn_os.h" 31 | #include "kmp_ftn_entry.h" 32 | #else 33 | "no"; 34 | #endif /* KMP_FTN_ENTRIES */ 35 | -------------------------------------------------------------------------------- /runtime/src/kmp_ftn_extra.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * kmp_ftn_extra.cpp -- Fortran 'extra' linkage support for OpenMP. 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // See https://llvm.org/LICENSE.txt for license information. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "kmp.h" 14 | #include "kmp_affinity.h" 15 | 16 | #if KMP_OS_WINDOWS 17 | #define KMP_FTN_ENTRIES KMP_FTN_PLAIN 18 | #elif KMP_OS_UNIX 19 | #define KMP_FTN_ENTRIES KMP_FTN_APPEND 20 | #endif 21 | 22 | // Note: This string is not printed when KMP_VERSION=1. 23 | char const __kmp_version_ftnextra[] = 24 | KMP_VERSION_PREFIX "Fortran \"extra\" OMP support: " 25 | #ifdef KMP_FTN_ENTRIES 26 | "yes"; 27 | #define FTN_STDCALL /* nothing to do */ 28 | #include "kmp_ftn_os.h" 29 | #include "kmp_ftn_entry.h" 30 | #else 31 | "no"; 32 | #endif /* KMP_FTN_ENTRIES */ 33 | -------------------------------------------------------------------------------- /runtime/src/kmp_ftn_stdcall.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * kmp_ftn_stdcall.cpp -- Fortran __stdcall linkage support for OpenMP. 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // See https://llvm.org/LICENSE.txt for license information. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "kmp.h" 14 | 15 | // Note: This string is not printed when KMP_VERSION=1. 16 | char const __kmp_version_ftnstdcall[] = 17 | KMP_VERSION_PREFIX "Fortran __stdcall OMP support: " 18 | #ifdef USE_FTN_STDCALL 19 | "yes"; 20 | #else 21 | "no"; 22 | #endif 23 | 24 | #ifdef USE_FTN_STDCALL 25 | 26 | #define FTN_STDCALL KMP_STDCALL 27 | #define KMP_FTN_ENTRIES USE_FTN_STDCALL 28 | 29 | #include "kmp_ftn_entry.h" 30 | #include "kmp_ftn_os.h" 31 | 32 | #endif /* USE_FTN_STDCALL */ 33 | -------------------------------------------------------------------------------- /runtime/src/kmp_import.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * kmp_import.cpp 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // See https://llvm.org/LICENSE.txt for license information. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | /* Object generated from this source file is linked to Windows* OS DLL import 14 | library (libompmd.lib) only! It is not a part of regular static or dynamic 15 | OpenMP RTL. Any code that just needs to go in the libompmd.lib (but not in 16 | libompmt.lib and libompmd.dll) should be placed in this file. */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /*These symbols are required for mutual exclusion with Microsoft OpenMP RTL 23 | (and compatibility with MS Compiler). */ 24 | 25 | int _You_must_link_with_exactly_one_OpenMP_library = 1; 26 | int _You_must_link_with_Intel_OpenMP_library = 1; 27 | int _You_must_link_with_Microsoft_OpenMP_library = 1; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | // end of file // 34 | -------------------------------------------------------------------------------- /runtime/src/kmp_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * kmp_io.h -- RTL IO header file. 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // See https://llvm.org/LICENSE.txt for license information. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef KMP_IO_H 14 | #define KMP_IO_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* ------------------------------------------------------------------------ */ 21 | 22 | enum kmp_io { kmp_out = 0, kmp_err }; 23 | 24 | extern kmp_bootstrap_lock_t __kmp_stdio_lock; /* Control stdio functions */ 25 | extern kmp_bootstrap_lock_t 26 | __kmp_console_lock; /* Control console initialization */ 27 | 28 | extern void __kmp_vprintf(enum kmp_io stream, char const *format, va_list ap); 29 | extern void __kmp_printf(char const *format, ...); 30 | extern void __kmp_printf_no_lock(char const *format, ...); 31 | extern void __kmp_fprintf(enum kmp_io stream, char const *format, ...); 32 | extern void __kmp_close_console(void); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* KMP_IO_H */ 39 | -------------------------------------------------------------------------------- /runtime/src/test-touch.c: -------------------------------------------------------------------------------- 1 | // test-touch.c // 2 | 3 | 4 | //===----------------------------------------------------------------------===// 5 | // 6 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 7 | // See https://llvm.org/LICENSE.txt for license information. 8 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 9 | // 10 | //===----------------------------------------------------------------------===// 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | extern double omp_get_wtime(); 17 | extern int omp_get_num_threads(); 18 | extern int omp_get_max_threads(); 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | int main() { 24 | omp_get_wtime(); 25 | omp_get_num_threads(); 26 | omp_get_max_threads(); 27 | return 0; 28 | } 29 | 30 | // end of file // 31 | -------------------------------------------------------------------------------- /runtime/test/affinity/bug-nested.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_AFFINITY=compact %libomp-run 2 | 3 | #include 4 | #include 5 | #include 6 | #include "omp_testsuite.h" 7 | 8 | int test_nested_affinity_bug() { 9 | int a = 0; 10 | omp_set_nested(1); 11 | #pragma omp parallel num_threads(2) shared(a) 12 | { 13 | #pragma omp parallel num_threads(2) shared(a) proc_bind(close) 14 | { 15 | #pragma omp atomic 16 | a++; 17 | } 18 | } 19 | return 1; 20 | } 21 | 22 | int main() { 23 | int i; 24 | int num_failed = 0; 25 | 26 | for (i = 0; i < REPETITIONS; i++) { 27 | if (!test_nested_affinity_bug()) { 28 | num_failed++; 29 | } 30 | } 31 | return num_failed; 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/increase.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | %python %S/check.py -c 'CHECK' %s 2 | // REQUIRES: !abt 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char** argv) { 9 | omp_set_affinity_format("TESTER: tl:%L tn:%n nt:%N"); 10 | // should print all for first parallel 11 | omp_set_num_threads(4); 12 | #pragma omp parallel 13 | { } 14 | // should print all because of new threads 15 | omp_set_num_threads(8); 16 | #pragma omp parallel 17 | { } 18 | // should not print anything here 19 | omp_set_num_threads(6); 20 | #pragma omp parallel 21 | { } 22 | // should print all because of new thread 23 | omp_set_num_threads(9); 24 | #pragma omp parallel 25 | { } 26 | // should not print anything here 27 | omp_set_num_threads(2); 28 | #pragma omp parallel 29 | { } 30 | return 0; 31 | } 32 | 33 | // CHECK: num_threads=4 TESTER: tl:1 tn:[0-3] nt:4 34 | // CHECK: num_threads=8 TESTER: tl:1 tn:[0-7] nt:8 35 | // CHECK: num_threads=6 TESTER: tl:1 tn:[0-5] nt:6 36 | // CHECK: num_threads=9 TESTER: tl:1 tn:[0-8] nt:9 37 | // CHECK: num_threads=2 TESTER: tl:1 tn:[01] nt:2 38 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/lit.local.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmodels/bolt/c1dc0e6e6ff6355319efa8f6c1dde7f02031afbf/runtime/test/affinity/format/lit.local.cfg -------------------------------------------------------------------------------- /runtime/test/affinity/format/nested.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close %libomp-run | %python %S/check.py -c 'CHECK' %s 2 | // REQUIRES: affinity && !abt 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char** argv) { 9 | omp_set_affinity_format("TESTER: tl:%L at:%a tn:%n nt:%N"); 10 | omp_set_nested(1); 11 | #pragma omp parallel num_threads(4) 12 | { 13 | #pragma omp parallel num_threads(3) 14 | { } 15 | } 16 | return 0; 17 | } 18 | 19 | // CHECK: num_threads=4 TESTER: tl:1 at:0 tn:[0-3] nt:4 20 | // CHECK: num_threads=3 TESTER: tl:2 at:[0-3] tn:[0-2] nt:3 21 | // CHECK: num_threads=3 TESTER: tl:2 at:[0-3] tn:[0-2] nt:3 22 | // CHECK: num_threads=3 TESTER: tl:2 at:[0-3] tn:[0-2] nt:3 23 | // CHECK: num_threads=3 TESTER: tl:2 at:[0-3] tn:[0-2] nt:3 24 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/nested2.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES=threads OMP_PROC_BIND=spread,close KMP_HOT_TEAMS_MAX_LEVEL=2 %libomp-run | %python %S/check.py -c 'CHECK' %s 2 | // REQUIRES: !abt 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | // Currently, KMP_HOT_TEAMS_MAX_LEVEL has to be equal to the 9 | // nest depth for intuitive behavior 10 | int main(int argc, char** argv) { 11 | omp_set_affinity_format("TESTER: tl:%L tn:%n nt:%N"); 12 | omp_set_nested(1); 13 | #pragma omp parallel num_threads(4) 14 | { 15 | #pragma omp parallel num_threads(3) 16 | { } 17 | #pragma omp parallel num_threads(3) 18 | { } 19 | } 20 | #pragma omp parallel num_threads(4) 21 | { } 22 | return 0; 23 | } 24 | 25 | // CHECK: num_threads=4 TESTER: tl:1 tn:[0-3] nt:4 26 | // CHECK: num_threads=3 TESTER: tl:2 tn:[0-2] nt:3 27 | // CHECK: num_threads=3 TESTER: tl:2 tn:[0-2] nt:3 28 | // CHECK: num_threads=3 TESTER: tl:2 tn:[0-2] nt:3 29 | // CHECK: num_threads=3 TESTER: tl:2 tn:[0-2] nt:3 30 | // CHECK: num_threads=4 TESTER: tl:1 tn:[0-3] nt:4 31 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/nested_serial.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true %libomp-run | %python %S/check.py -c 'CHECK' %s 2 | // REQUIRES: !abt 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char** argv) { 9 | omp_set_affinity_format("TESTER: tl:%L at:%a tn:%n nt:%N"); 10 | omp_set_nested(1); 11 | #pragma omp parallel num_threads(1) 12 | { 13 | #pragma omp parallel num_threads(1) 14 | { } 15 | #pragma omp parallel num_threads(1) 16 | { } 17 | #pragma omp parallel num_threads(1) 18 | { 19 | #pragma omp parallel num_threads(1) 20 | { } 21 | } 22 | #pragma omp parallel num_threads(1) 23 | { } 24 | } 25 | #pragma omp parallel num_threads(1) 26 | { } 27 | #pragma omp parallel num_threads(1) 28 | { } 29 | return 0; 30 | } 31 | 32 | // CHECK: num_threads=1 TESTER: tl:1 at:0 tn:0 nt:1 33 | // CHECK: num_threads=1 TESTER: tl:2 at:0 tn:0 nt:1 34 | // CHECK: num_threads=1 TESTER: tl:3 at:0 tn:0 nt:1 35 | // CHECK: num_threads=1 TESTER: tl:2 at:0 tn:0 nt:1 36 | // CHECK: num_threads=1 TESTER: tl:1 at:0 tn:0 nt:1 37 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/proc_bind.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_DISPLAY_AFFINITY=true OMP_PLACES='{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0},{0,1},{0}' %libomp-run | %python %S/check.py -c 'CHECK' %s 2 | // REQUIRES: affinity && !abt 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char** argv) { 9 | omp_set_affinity_format("TESTER: tl:%L tn:%n nt:%N aff:{%A}"); 10 | omp_set_num_threads(8); 11 | // Initial parallel 12 | #pragma omp parallel proc_bind(spread) 13 | { } 14 | #pragma omp parallel proc_bind(spread) 15 | { } 16 | // Affinity changes here 17 | #pragma omp parallel proc_bind(close) 18 | { } 19 | #pragma omp parallel proc_bind(close) 20 | { } 21 | // Affinity changes here 22 | #pragma omp parallel proc_bind(master) 23 | { } 24 | #pragma omp parallel proc_bind(master) 25 | { } 26 | return 0; 27 | } 28 | 29 | // CHECK: num_threads=8 TESTER: tl:1 tn:[0-7] nt:8 aff: 30 | // CHECK: num_threads=8 TESTER: tl:1 tn:[0-7] nt:8 aff: 31 | // CHECK: num_threads=8 TESTER: tl:1 tn:[0-7] nt:8 aff: 32 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/simple.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile 2 | // RUN: env OMP_DISPLAY_AFFINITY=false %libomp-run | %python %S/check.py -c 'NOTHING' %s 3 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=1 %libomp-run | %python %S/check.py -c 'CHECK' %s 4 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=2 %libomp-run | %python %S/check.py -c 'CHECK-2' %s 5 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=3 %libomp-run | %python %S/check.py -c 'CHECK-3' %s 6 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=4 %libomp-run | %python %S/check.py -c 'CHECK-4' %s 7 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_NUM_THREADS=8 %libomp-run | %python %S/check.py -c 'CHECK-8' %s 8 | // REQUIRES: !abt 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char** argv) { 15 | omp_set_affinity_format("TESTER: tl:%L tn:%n nt:%N"); 16 | #pragma omp parallel 17 | { } 18 | #pragma omp parallel 19 | { } 20 | return 0; 21 | } 22 | 23 | // NOTHING: NO_OUTPUT 24 | // CHECK: num_threads=1 TESTER: tl:1 tn:0 nt:1 25 | // CHECK-2: num_threads=2 TESTER: tl:1 tn:[01] nt:2 26 | // CHECK-3: num_threads=3 TESTER: tl:1 tn:[0-2] nt:3 27 | // CHECK-4: num_threads=4 TESTER: tl:1 tn:[0-3] nt:4 28 | // CHECK-8: num_threads=8 TESTER: tl:1 tn:[0-7] nt:8 29 | -------------------------------------------------------------------------------- /runtime/test/affinity/format/simple_env.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile 2 | // RUN: env OMP_DISPLAY_AFFINITY=true OMP_AFFINITY_FORMAT='TESTER-ENV: tl:%L tn:%n nt:%N' OMP_NUM_THREADS=8 %libomp-run | %python %S/check.py -c 'CHECK-8' %s 3 | // REQUIRES: !abt 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char** argv) { 10 | #pragma omp parallel 11 | { } 12 | #pragma omp parallel 13 | { } 14 | return 0; 15 | } 16 | 17 | // CHECK-8: num_threads=8 TESTER-ENV: tl:1 tn:[0-7] nt:8$ 18 | -------------------------------------------------------------------------------- /runtime/test/api/has_openmp.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_has_openmp() 7 | { 8 | int rvalue = 0; 9 | #ifdef _OPENMP 10 | rvalue = 1; 11 | #endif 12 | return (rvalue); 13 | } 14 | 15 | int main() 16 | { 17 | int i; 18 | int num_failed=0; 19 | if(!test_has_openmp()) { 20 | num_failed++; 21 | } 22 | return num_failed; 23 | } 24 | -------------------------------------------------------------------------------- /runtime/test/api/kmp_set_defaults_lock_bug.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | /* The bug occurs if the lock table is reallocated after 5 | kmp_set_defaults() is called. If the table is reallocated, 6 | then the lock will not point to a valid lock object after the 7 | kmp_set_defaults() call.*/ 8 | omp_lock_t lock; 9 | 10 | int test_kmp_set_defaults_lock_bug() 11 | { 12 | /* checks that omp_get_num_threads is equal to the number of 13 | threads */ 14 | int nthreads_lib; 15 | int nthreads = 0; 16 | 17 | nthreads_lib = -1; 18 | 19 | #pragma omp parallel 20 | { 21 | omp_set_lock(&lock); 22 | nthreads++; 23 | omp_unset_lock(&lock); 24 | #pragma omp single 25 | { 26 | nthreads_lib = omp_get_num_threads (); 27 | } /* end of single */ 28 | } /* end of parallel */ 29 | kmp_set_defaults("OMP_NUM_THREADS"); 30 | #pragma omp parallel 31 | { 32 | omp_set_lock(&lock); 33 | nthreads++; 34 | omp_unset_lock(&lock); 35 | } /* end of parallel */ 36 | 37 | return (nthreads == 2*nthreads_lib); 38 | } 39 | 40 | int main() 41 | { 42 | int i; 43 | int num_failed=0; 44 | omp_init_lock(&lock); 45 | 46 | for(i = 0; i < REPETITIONS; i++) { 47 | if(!test_kmp_set_defaults_lock_bug()) { 48 | num_failed++; 49 | } 50 | } 51 | omp_destroy_lock(&lock); 52 | return num_failed; 53 | } 54 | -------------------------------------------------------------------------------- /runtime/test/api/omp_alloc_def_fb.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | omp_alloctrait_t at[2]; 8 | omp_allocator_handle_t a; 9 | void *p[2]; 10 | at[0].key = omp_atk_pool_size; 11 | at[0].value = 2 * 1024 * 1024; 12 | at[1].key = omp_atk_fallback; 13 | at[1].value = omp_atv_default_mem_fb; 14 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 15 | printf("allocator large created: %p\n", (void *)a); 16 | #pragma omp parallel num_threads(2) 17 | { 18 | int i = omp_get_thread_num(); 19 | p[i] = omp_alloc(1024 * 1024, a); 20 | #pragma omp barrier 21 | printf("th %d, ptr %p\n", i, p[i]); 22 | omp_free(p[i], a); 23 | } 24 | // Both pointers should be non-NULL 25 | if (p[0] != NULL && p[1] != NULL) { 26 | printf("passed\n"); 27 | return 0; 28 | } else { 29 | printf("failed: pointers %p %p\n", p[0], p[1]); 30 | return 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/api/omp_alloc_null_fb.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | omp_alloctrait_t at[2]; 8 | omp_allocator_handle_t a; 9 | void *p[2]; 10 | at[0].key = omp_atk_pool_size; 11 | at[0].value = 2 * 1024 * 1024; 12 | at[1].key = omp_atk_fallback; 13 | at[1].value = omp_atv_null_fb; 14 | a = omp_init_allocator(omp_default_mem_space, 2, at); 15 | printf("allocator created: %p\n", (void *)a); 16 | #pragma omp parallel num_threads(2) 17 | { 18 | int i = omp_get_thread_num(); 19 | #pragma omp barrier 20 | p[i] = omp_alloc(1024 * 1024, a); 21 | #pragma omp barrier 22 | printf("th %d, ptr %p\n", i, p[i]); 23 | omp_free(p[i], a); 24 | } 25 | // As an allocator has some small memory overhead 26 | // exactly one of the two pointers should be NULL 27 | // because of NULL fallback requested 28 | if ((p[0] == NULL && p[1] != NULL) || (p[0] != NULL && p[1] == NULL)) { 29 | printf("passed\n"); 30 | return 0; 31 | } else { 32 | printf("failed: pointers %p %p\n", p[0], p[1]); 33 | return 1; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /runtime/test/api/omp_calloc_def_fb.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | omp_alloctrait_t at[2]; 8 | omp_allocator_handle_t a; 9 | void *p[2]; 10 | at[0].key = omp_atk_pool_size; 11 | at[0].value = 2 * 1024 * 1024; 12 | at[1].key = omp_atk_fallback; 13 | at[1].value = omp_atv_default_mem_fb; 14 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 15 | printf("allocator large created: %p\n", (void *)a); 16 | #pragma omp parallel num_threads(2) 17 | { 18 | int i = omp_get_thread_num(); 19 | p[i] = omp_calloc(1024, 1024, a); 20 | #pragma omp barrier 21 | printf("th %d, ptr %p\n", i, p[i]); 22 | omp_free(p[i], a); 23 | } 24 | // Both pointers should be non-NULL 25 | if (p[0] != NULL && p[1] != NULL) { 26 | printf("passed\n"); 27 | return 0; 28 | } else { 29 | printf("failed: pointers %p %p\n", p[0], p[1]); 30 | return 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/api/omp_calloc_size_0.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | omp_alloctrait_t at[2]; 9 | omp_allocator_handle_t a; 10 | void *p[2]; 11 | at[0].key = omp_atk_pool_size; 12 | at[0].value = 2*1024*1024; 13 | at[1].key = omp_atk_fallback; 14 | at[1].value = omp_atv_default_mem_fb; 15 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 16 | printf("allocator large created: %p\n", (void *)a); 17 | #pragma omp parallel num_threads(2) 18 | { 19 | int i = omp_get_thread_num(); 20 | p[i] = omp_calloc(1024, 0, a); 21 | #pragma omp barrier 22 | printf("th %d, ptr %p\n", i, p[i]); 23 | omp_free(p[i], a); 24 | } 25 | // Both pointers should be NULL 26 | if (p[0] == NULL && p[1] == NULL) { 27 | printf("passed\n"); 28 | return 0; 29 | } else { 30 | printf("failed: pointers %p %p\n", p[0], p[1]); 31 | return 1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /runtime/test/api/omp_display_env0.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2>&1 | FileCheck %s 2 | // RUN: %libomp-cxx-compile-c && %libomp-run 2>&1 | FileCheck %s 3 | #include 4 | #include 5 | int main() 6 | { 7 | omp_display_env(0); 8 | printf("passed\n"); 9 | return 0; 10 | } 11 | 12 | // CHECK: OPENMP DISPLAY ENVIRONMENT BEGIN 13 | // CHECK: _OPENMP 14 | // CHECK: OPENMP DISPLAY ENVIRONMENT END 15 | -------------------------------------------------------------------------------- /runtime/test/api/omp_get_num_devices.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // UNSUPPORTED: icc-16, icc-17, icc-18 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_omp_get_num_devices() 7 | { 8 | /* checks that omp_get_device_num */ 9 | int num_devices = omp_get_num_devices(); 10 | 11 | return (num_devices == 0); 12 | } 13 | 14 | int main() 15 | { 16 | int i; 17 | int num_failed=0; 18 | 19 | for(i = 0; i < REPETITIONS; i++) { 20 | if(!test_omp_get_num_devices()) { 21 | num_failed++; 22 | } 23 | } 24 | return num_failed; 25 | } 26 | -------------------------------------------------------------------------------- /runtime/test/api/omp_get_num_threads.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_get_num_threads() 6 | { 7 | /* checks that omp_get_num_threads is equal to the number of 8 | threads */ 9 | int nthreads_lib; 10 | int nthreads = 0; 11 | 12 | nthreads_lib = -1; 13 | 14 | #pragma omp parallel 15 | { 16 | #pragma omp critical 17 | { 18 | nthreads++; 19 | } /* end of critical */ 20 | #pragma omp single 21 | { 22 | nthreads_lib = omp_get_num_threads (); 23 | } /* end of single */ 24 | } /* end of parallel */ 25 | return (nthreads == nthreads_lib); 26 | } 27 | 28 | int main() 29 | { 30 | int i; 31 | int num_failed=0; 32 | 33 | for(i = 0; i < REPETITIONS; i++) { 34 | if(!test_omp_get_num_threads()) { 35 | num_failed++; 36 | } 37 | } 38 | return num_failed; 39 | } 40 | -------------------------------------------------------------------------------- /runtime/test/api/omp_get_wtick.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_get_wtick() 6 | { 7 | double tick; 8 | tick = -1.; 9 | tick = omp_get_wtick (); 10 | return ((tick > 0.0) && (tick <= 0.01)); 11 | } 12 | 13 | int main() 14 | { 15 | int i; 16 | int num_failed=0; 17 | 18 | for(i = 0; i < REPETITIONS; i++) { 19 | if(!test_omp_get_wtick()) { 20 | num_failed++; 21 | } 22 | } 23 | return num_failed; 24 | } 25 | -------------------------------------------------------------------------------- /runtime/test/api/omp_get_wtime.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | #include "omp_my_sleep.h" 6 | 7 | int test_omp_get_wtime() 8 | { 9 | double start; 10 | double end; 11 | double measured_time; 12 | double wait_time = 5.0; 13 | start = 0; 14 | end = 0; 15 | start = omp_get_wtime(); 16 | my_sleep (wait_time); 17 | end = omp_get_wtime(); 18 | measured_time = end-start; 19 | return ((measured_time > 0.97 * wait_time) && (measured_time < 1.03 * wait_time)) ; 20 | } 21 | 22 | int main() 23 | { 24 | int i; 25 | int num_failed=0; 26 | 27 | for(i = 0; i < REPETITIONS; i++) { 28 | if(!test_omp_get_wtime()) { 29 | num_failed++; 30 | } 31 | } 32 | return num_failed; 33 | } 34 | -------------------------------------------------------------------------------- /runtime/test/api/omp_in_parallel.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | /* 6 | * Checks that false is returned when called from serial region 7 | * and true is returned when called within parallel region. 8 | */ 9 | int test_omp_in_parallel() 10 | { 11 | int serial; 12 | int isparallel; 13 | 14 | serial = 1; 15 | isparallel = 0; 16 | serial = omp_in_parallel(); 17 | 18 | #pragma omp parallel 19 | { 20 | #pragma omp single 21 | { 22 | isparallel = omp_in_parallel(); 23 | } 24 | } 25 | return (!(serial) && isparallel); 26 | } 27 | 28 | int main() 29 | { 30 | int i; 31 | int num_failed=0; 32 | 33 | // the test requires more than 1 thread to pass 34 | omp_set_dynamic(0); // disable dynamic adjustment of threads 35 | if (omp_get_max_threads() == 1) 36 | omp_set_num_threads(2); // set 2 threads if no HW resources available 37 | 38 | for(i = 0; i < REPETITIONS; i++) { 39 | if(!test_omp_in_parallel()) { 40 | num_failed++; 41 | } 42 | } 43 | return num_failed; 44 | } 45 | -------------------------------------------------------------------------------- /runtime/test/api/omp_pause_resource.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_pause_resource() { 6 | int fails, nthreads, my_dev; 7 | 8 | fails = 0; 9 | nthreads = 0; 10 | my_dev = omp_get_initial_device(); 11 | 12 | #pragma omp parallel 13 | #pragma omp single 14 | nthreads = omp_get_num_threads(); 15 | 16 | if (omp_pause_resource(omp_pause_soft, my_dev)) 17 | fails++; 18 | 19 | #pragma omp parallel shared(nthreads) 20 | #pragma omp single 21 | nthreads = omp_get_num_threads(); 22 | 23 | if (nthreads == 0) 24 | fails++; 25 | if (omp_pause_resource(omp_pause_hard, my_dev)) 26 | fails++; 27 | nthreads = 0; 28 | 29 | #pragma omp parallel shared(nthreads) 30 | #pragma omp single 31 | nthreads = omp_get_num_threads(); 32 | 33 | if (nthreads == 0) 34 | fails++; 35 | if (omp_pause_resource_all(omp_pause_soft)) 36 | fails++; 37 | nthreads = 0; 38 | 39 | #pragma omp parallel shared(nthreads) 40 | #pragma omp single 41 | nthreads = omp_get_num_threads(); 42 | 43 | if (nthreads == 0) 44 | fails++; 45 | return fails == 0; 46 | } 47 | 48 | int main() { 49 | int i; 50 | int num_failed = 0; 51 | 52 | for (i = 0; i < REPETITIONS; i++) { 53 | if (!test_omp_pause_resource()) { 54 | num_failed++; 55 | } 56 | } 57 | return num_failed; 58 | } 59 | -------------------------------------------------------------------------------- /runtime/test/api/omp_realloc_def_fb.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | omp_alloctrait_t at[2]; 8 | omp_allocator_handle_t a; 9 | omp_allocator_handle_t f_a; 10 | void *ptr[2]; 11 | void *nptr[2]; 12 | at[0].key = omp_atk_pool_size; 13 | at[0].value = 2 * 1024 * 1024; 14 | at[1].key = omp_atk_fallback; 15 | at[1].value = omp_atv_default_mem_fb; 16 | 17 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 18 | f_a = omp_init_allocator(omp_default_mem_space, 2, at); 19 | printf("allocator large created: %p\n", (void *)a); 20 | printf("allocator default created: %p\n", (void *)f_a); 21 | 22 | #pragma omp parallel num_threads(2) 23 | { 24 | int i = omp_get_thread_num(); 25 | ptr[i] = omp_alloc(1024 * 1024, f_a); 26 | #pragma omp barrier 27 | nptr[i] = omp_realloc(ptr[i], 1024 * 1024, a, f_a); 28 | #pragma omp barrier 29 | printf("th %d, nptr %p\n", i, nptr[i]); 30 | omp_free(nptr[i], a); 31 | } 32 | // Both pointers should be non-NULL 33 | if (nptr[0] != NULL && nptr[1] != NULL) { 34 | printf("passed\n"); 35 | return 0; 36 | } else { 37 | printf("failed: pointers %p %p\n", nptr[0], nptr[1]); 38 | return 1; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /runtime/test/api/omp_realloc_null_ptr.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | omp_alloctrait_t at[2]; 9 | omp_allocator_handle_t a; 10 | omp_allocator_handle_t f_a; 11 | void *ptr[2]; 12 | void *nptr[2]; 13 | at[0].key = omp_atk_pool_size; 14 | at[0].value = 2*1024*1024; 15 | at[1].key = omp_atk_fallback; 16 | at[1].value = omp_atv_default_mem_fb; 17 | 18 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 19 | f_a = omp_init_allocator(omp_default_mem_space, 2, at); 20 | printf("allocator large created: %p\n", (void *)a); 21 | printf("allocator default created: %p\n", (void *)f_a); 22 | 23 | #pragma omp parallel num_threads(2) 24 | { 25 | int i = omp_get_thread_num(); 26 | ptr[i] = omp_alloc(0, f_a); 27 | #pragma omp barrier 28 | nptr[i] = omp_realloc(ptr[i], 1024 * 1024, a, f_a); 29 | #pragma omp barrier 30 | printf("th %d, nptr %p\n", i, nptr[i]); 31 | omp_free(nptr[i], a); 32 | } 33 | 34 | // Both ptr pointers should be NULL 35 | if (ptr[0] != NULL || ptr[1] != NULL) { 36 | printf("failed: pointers %p %p\n", ptr[0], ptr[1]); 37 | return 1; 38 | } 39 | // Both nptr pointers should be non-NULL 40 | if (nptr[0] == NULL || nptr[1] == NULL) { 41 | printf("failed: pointers %p %p\n", nptr[0], nptr[1]); 42 | return 1; 43 | } 44 | printf("passed\n"); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/api/omp_realloc_size_0.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | omp_alloctrait_t at[2]; 9 | omp_allocator_handle_t a; 10 | omp_allocator_handle_t f_a; 11 | void *ptr[2]; 12 | void *nptr[2]; 13 | at[0].key = omp_atk_pool_size; 14 | at[0].value = 2*1024*1024; 15 | at[1].key = omp_atk_fallback; 16 | at[1].value = omp_atv_default_mem_fb; 17 | 18 | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); 19 | f_a = omp_init_allocator(omp_default_mem_space, 2, at); 20 | printf("allocator large created: %p\n", (void *)a); 21 | printf("allocator default created: %p\n", (void *)f_a); 22 | 23 | #pragma omp parallel num_threads(2) 24 | { 25 | int i = omp_get_thread_num(); 26 | ptr[i] = omp_alloc(1024 * 1024, f_a); 27 | #pragma omp barrier 28 | nptr[i] = omp_realloc(ptr[i], 0, a, f_a); 29 | #pragma omp barrier 30 | printf("th %d, nptr %p\n", i, nptr[i]); 31 | omp_free(nptr[i], a); 32 | } 33 | 34 | // Both ptr pointers should be non-NULL 35 | if (ptr[0] == NULL || ptr[1] == NULL) { 36 | printf("failed: pointers %p %p\n", ptr[0], ptr[1]); 37 | return 1; 38 | } 39 | // Both nptr pointers should be NULL 40 | if (nptr[0] != NULL || nptr[1] != NULL) { 41 | printf("failed: pointers %p %p\n", nptr[0], nptr[1]); 42 | return 1; 43 | } 44 | printf("passed\n"); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/bolt/interop/init_then_openmp.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include 5 | 6 | int test_init_then_openmp(int num_init) { 7 | int i; 8 | int val = 0; 9 | 10 | for (i = 0; i < num_init; i++) { 11 | ABT_EXIT_IF_FAIL(ABT_init(0, 0)); 12 | } 13 | 14 | #pragma omp parallel num_threads(NUM_TASKS) 15 | { 16 | #pragma omp master 17 | { val = 1; } 18 | } 19 | 20 | for (i = 0; i < num_init; i++) { 21 | ABT_EXIT_IF_FAIL(ABT_finalize()); 22 | } 23 | 24 | return val; 25 | } 26 | 27 | int main() { 28 | int i; 29 | int num_failed = 0; 30 | for (i = 0; i < REPETITIONS; i++) { 31 | // Note that Argobots will be initialized once BOLT is instantiated. 32 | if (!test_init_then_openmp(i + 1)) { 33 | num_failed++; 34 | } 35 | } 36 | return num_failed; 37 | } 38 | -------------------------------------------------------------------------------- /runtime/test/bolt/interop/openmp_then_init.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include 5 | 6 | int test_openmp_then_init(int num_init) { 7 | int i; 8 | int val = 0; 9 | 10 | #pragma omp parallel num_threads(NUM_TASKS) 11 | { 12 | #pragma omp master 13 | { 14 | int initialized = (ABT_initialized() == ABT_SUCCESS); 15 | for (i = 0; i < num_init; i++) { 16 | ABT_EXIT_IF_FAIL(ABT_init(0, 0)); 17 | } 18 | val = initialized ? 1 : 0; 19 | for (i = 0; i < num_init; i++) { 20 | ABT_EXIT_IF_FAIL(ABT_finalize()); 21 | } 22 | } 23 | } 24 | return val; 25 | } 26 | 27 | int main() { 28 | int i; 29 | int num_failed = 0; 30 | for (i = 0; i < REPETITIONS; i++) { 31 | // Note that Argobots will be initialized once BOLT is instantiated. 32 | if (!test_openmp_then_init(i + 1)) { 33 | num_failed++; 34 | } 35 | } 36 | return num_failed; 37 | } 38 | -------------------------------------------------------------------------------- /runtime/test/bolt/misc_bugs/untied_tasks.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_untied_tasks() 6 | { 7 | // https://github.com/pmodels/bolt/issues/49 8 | int val = 0; 9 | #pragma omp parallel 10 | #pragma omp master 11 | { 12 | #pragma omp task untied 13 | { val = 1; } 14 | } 15 | return val; 16 | } 17 | 18 | int test_omp_tied_tasks() 19 | { 20 | int val = 0; 21 | #pragma omp parallel 22 | #pragma omp master 23 | { 24 | #pragma omp task 25 | { val = 1; } 26 | } 27 | return val; 28 | } 29 | 30 | int test_omp_tied_and_untied_tasks() 31 | { 32 | int val1 = 0; 33 | int val2 = 0; 34 | #pragma omp parallel 35 | #pragma omp master 36 | { 37 | #pragma omp task 38 | { val1 = 1; } 39 | #pragma omp task untied 40 | { val2 = 1; } 41 | } 42 | return val1 == 1 && val2 == 1; 43 | } 44 | 45 | int main() 46 | { 47 | int i; 48 | int num_failed = 0; 49 | for (i = 0; i < REPETITIONS; i++) { 50 | if (!test_omp_untied_tasks()) { 51 | num_failed++; 52 | } 53 | if (!test_omp_tied_tasks()) { 54 | num_failed++; 55 | } 56 | if (!test_omp_tied_and_untied_tasks()) { 57 | num_failed++; 58 | } 59 | } 60 | return num_failed; 61 | } 62 | -------------------------------------------------------------------------------- /runtime/test/bolt/scheduling/for_nowait_scheduling.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ABT_NUM_ESS=4 %libomp-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include "bolt_scheduling_util.h" 5 | 6 | int test_for_nowait_scheduling() { 7 | int i, vals[4]; 8 | memset(vals, 0, sizeof(int) * 4); 9 | 10 | timeout_barrier_t barrier; 11 | timeout_barrier_init(&barrier); 12 | 13 | #pragma omp parallel num_threads(4) 14 | { 15 | check_num_ess(4); 16 | int tid = omp_get_thread_num(); 17 | #pragma omp for nowait 18 | for (i = 0; i < 4; i++) { 19 | if (tid < 2) { 20 | timeout_barrier_wait(&barrier, 4); 21 | } 22 | } 23 | if (tid >= 2) { 24 | // The following barrier must be synchronized with the "for" above. 25 | timeout_barrier_wait(&barrier, 4); 26 | } 27 | vals[omp_get_thread_num()] = 1; 28 | } 29 | 30 | for (i = 0; i < 4; i++) { 31 | if (vals[i] != 1) { 32 | printf("vals[%d] == %d\n", i, vals[i]); 33 | return 0; 34 | } 35 | } 36 | return 1; 37 | } 38 | 39 | int main() { 40 | int i, num_failed = 0; 41 | for (i = 1; i < REPETITIONS; i++) { 42 | if (!test_for_nowait_scheduling(i)) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/bolt/scheduling/task_tied_scheduling.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ABT_NUM_ESS=4 %libomp-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include "bolt_scheduling_util.h" 5 | 6 | int test_task_tied_scheduling() { 7 | int i, vals[6]; 8 | memset(vals, 0, sizeof(int) * 6); 9 | 10 | timeout_barrier_t barrier; 11 | timeout_barrier_init(&barrier); 12 | 13 | #pragma omp parallel num_threads(4) 14 | { 15 | // 6 barrier_waits in tasks and 2 barrier_waits in threads 16 | #pragma omp master 17 | { 18 | check_num_ess(4); 19 | for (i = 0; i < 6; i++) { 20 | #pragma omp task firstprivate(i) 21 | { 22 | timeout_barrier_wait(&barrier, 4); 23 | vals[i] = 1; 24 | } 25 | } 26 | } 27 | if (omp_get_thread_num() < 2) { 28 | timeout_barrier_wait(&barrier, 4); 29 | } 30 | } 31 | 32 | for (i = 0; i < 6; i++) { 33 | if (vals[i] != 1) { 34 | printf("vals[%d] == %d\n", i, vals[i]); 35 | return 0; 36 | } 37 | } 38 | return 1; 39 | } 40 | 41 | int main() { 42 | int i, num_failed = 0; 43 | for (i = 0; i < REPETITIONS; i++) { 44 | if (!test_task_tied_scheduling(i)) { 45 | num_failed++; 46 | } 47 | } 48 | return num_failed; 49 | } 50 | -------------------------------------------------------------------------------- /runtime/test/bolt/scheduling/taskloop_nogroup_tied_scheduling.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ABT_NUM_ESS=4 %libomp-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include "bolt_scheduling_util.h" 5 | 6 | int test_taskloop_nogroup_tied_scheduling() { 7 | int i, vals[6]; 8 | memset(vals, 0, sizeof(int) * 6); 9 | 10 | timeout_barrier_t barrier; 11 | timeout_barrier_init(&barrier); 12 | 13 | #pragma omp parallel num_threads(4) 14 | { 15 | // 6 barrier_waits in tasks and 2 barrier_waits in threads 16 | #pragma omp master 17 | { 18 | check_num_ess(4); 19 | #pragma omp taskloop grainsize(1) nogroup 20 | for (i = 0; i < 6; i++) { 21 | timeout_barrier_wait(&barrier, 4); 22 | vals[i] = 1; 23 | } 24 | } 25 | if (omp_get_thread_num() < 2) { 26 | // master does not wait the completion of taskloop. 27 | timeout_barrier_wait(&barrier, 4); 28 | } 29 | } 30 | 31 | for (i = 0; i < 6; i++) { 32 | if (vals[i] != 1) { 33 | printf("vals[%d] == %d\n", i, vals[i]); 34 | return 0; 35 | } 36 | } 37 | return 1; 38 | } 39 | 40 | int main() { 41 | int i, num_failed = 0; 42 | for (i = 0; i < REPETITIONS; i++) { 43 | if (!test_taskloop_nogroup_tied_scheduling()) { 44 | num_failed++; 45 | } 46 | } 47 | return num_failed; 48 | } 49 | -------------------------------------------------------------------------------- /runtime/test/bolt/scheduling/taskloop_tied_scheduling.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ABT_NUM_ESS=4 %libomp-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include "bolt_scheduling_util.h" 5 | 6 | int test_taskloop_tied_scheduling() { 7 | int i, vals[6]; 8 | memset(vals, 0, sizeof(int) * 6); 9 | 10 | timeout_barrier_t barrier; 11 | timeout_barrier_init(&barrier); 12 | 13 | #pragma omp parallel num_threads(4) 14 | { 15 | if (omp_get_thread_num() >= 2) { 16 | timeout_barrier_wait(&barrier, 4); 17 | } 18 | // 6 barrier_waits in tasks and 2 barrier_waits in threads 19 | #pragma omp master 20 | { 21 | check_num_ess(4); 22 | #pragma omp taskloop grainsize(1) 23 | for (i = 0; i < 6; i++) { 24 | timeout_barrier_wait(&barrier, 4); 25 | vals[i] = 1; 26 | } 27 | } 28 | } 29 | 30 | for (i = 0; i < 6; i++) { 31 | if (vals[i] != 1) { 32 | printf("vals[%d] == %d\n", i, vals[i]); 33 | return 0; 34 | } 35 | } 36 | return 1; 37 | } 38 | 39 | int main() { 40 | int i, num_failed = 0; 41 | for (i = 0; i < REPETITIONS; i++) { 42 | if (!test_taskloop_tied_scheduling()) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/bolt/scheduling/thread_scheduling.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ABT_NUM_ESS=4 %libomp-run 2 | // REQUIRES: abt 3 | #include "omp_testsuite.h" 4 | #include "bolt_scheduling_util.h" 5 | 6 | int test_thread_scheduling(int num_threads) { 7 | int i, vals[num_threads]; 8 | memset(vals, 0, sizeof(int) * num_threads); 9 | 10 | timeout_barrier_t barrier; 11 | timeout_barrier_init(&barrier); 12 | 13 | #pragma omp parallel num_threads(num_threads) 14 | { 15 | check_num_ess(4); 16 | // The barrier must be run by all ESs. 17 | timeout_barrier_wait(&barrier, 4); 18 | vals[omp_get_thread_num()] += 1; 19 | } 20 | 21 | #pragma omp parallel for num_threads(num_threads) 22 | for (i = 0; i < num_threads; i++) { 23 | check_num_ess(4); 24 | // The barrier must be run by all ESs. 25 | timeout_barrier_wait(&barrier, 4); 26 | vals[i] += 2; 27 | } 28 | 29 | for (i = 0; i < num_threads; i++) { 30 | if (vals[i] != 3) { 31 | printf("vals[%d] == %d\n", i, vals[i]); 32 | return 0; 33 | } 34 | } 35 | return 1; 36 | } 37 | 38 | int main() { 39 | int i, num_failed = 0; 40 | for (i = 1; i < 4; i++) { 41 | if (!test_thread_scheduling(i * 4)) { 42 | num_failed++; 43 | } 44 | } 45 | return num_failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/critical/omp_critical.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_critical() 6 | { 7 | int sum; 8 | int known_sum; 9 | 10 | sum=0; 11 | #pragma omp parallel 12 | { 13 | int mysum=0; 14 | int i; 15 | #pragma omp for 16 | for (i = 0; i < 1000; i++) 17 | mysum = mysum + i; 18 | 19 | #pragma omp critical 20 | sum = mysum +sum; 21 | } 22 | known_sum = 999 * 1000 / 2; 23 | return (known_sum == sum); 24 | } 25 | 26 | int main() 27 | { 28 | int i; 29 | int num_failed=0; 30 | 31 | for(i = 0; i < REPETITIONS; i++) { 32 | if(!test_omp_critical()) { 33 | num_failed++; 34 | } 35 | } 36 | return num_failed; 37 | } 38 | -------------------------------------------------------------------------------- /runtime/test/env/kmp_aff_disable_hwloc.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_AFFINITY=disabled KMP_TOPOLOGY_METHOD=hwloc %libomp-run 2 | // REQUIRES: hwloc 3 | #include 4 | #include 5 | 6 | // Test will assert() without fix 7 | int test_affinity_disabled_plus_hwloc() { 8 | #pragma omp parallel 9 | {} 10 | return 1; 11 | } 12 | 13 | int main(int argc, char **argv) { 14 | int i, j; 15 | int failed = 0; 16 | 17 | if (!test_affinity_disabled_plus_hwloc()) { 18 | failed = 1; 19 | } 20 | return failed; 21 | } 22 | -------------------------------------------------------------------------------- /runtime/test/env/omp_alloc_env_invalid.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile 2 | // RUN: env OMP_ALLOCATOR=111 %libomp-run 2>&1 | FileCheck %s 3 | // RUN: env OMP_ALLOCATOR=omp_default_mem_alloc_xyz %libomp-run 2>&1 | FileCheck %s 4 | // UNSUPPORTED: gcc 5 | 6 | // Both invocations of the test should produce (different) warnings: 7 | // OMP: Warning #42: OMP_ALLOCATOR: "111" is an invalid value; ignored. 8 | // OMP: Warning #189: Allocator omp_const_mem_alloc is not available, will use default allocator. 9 | #include 10 | #include 11 | int main() { 12 | volatile int n = omp_get_max_threads(); // causes library initialization 13 | return 0; 14 | } 15 | 16 | // CHECK: {{^OMP: Warning #[0-9]+}}: {{.*$}} 17 | -------------------------------------------------------------------------------- /runtime/test/env/omp_wait_policy.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_WAIT_POLICY=active %libomp-run active 2 | // RUN: %libomp-compile && env OMP_WAIT_POLICY=passive %libomp-run passive 3 | // 4 | // OMP_WAIT_POLICY=active should imply blocktime == INT_MAX 5 | // i.e., threads spin-wait forever 6 | // OMP_WAIT_POLICY=passive should imply blocktime == 0 7 | // i.e., threads immediately sleep 8 | #include 9 | #include 10 | #include 11 | #include "omp_testsuite.h" 12 | 13 | void usage() { 14 | fprintf(stderr, "usage: omp_wait_policy active|passive\n"); 15 | } 16 | 17 | int main(int argc, char** argv) 18 | { 19 | int blocktime, retval=1; 20 | const char* env_var_value; 21 | 22 | if (argc != 2) { 23 | usage(); 24 | return 1; 25 | } 26 | 27 | blocktime = kmp_get_blocktime(); 28 | 29 | env_var_value = argv[1]; 30 | if (!strcmp(env_var_value, "active")) { 31 | retval = (blocktime != INT_MAX); 32 | } else if (!strcmp(env_var_value, "passive")) { 33 | retval = (blocktime != 0); 34 | } else { 35 | usage(); 36 | retval = 1; 37 | } 38 | 39 | return retval; 40 | } 41 | -------------------------------------------------------------------------------- /runtime/test/flush/omp_flush.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | #include "omp_my_sleep.h" 5 | 6 | int test_omp_flush() 7 | { 8 | int result1; 9 | int result2; 10 | int dummy; 11 | 12 | result1 = 0; 13 | result2 = 0; 14 | 15 | #pragma omp parallel 16 | { 17 | int rank; 18 | rank = omp_get_thread_num (); 19 | #pragma omp barrier 20 | if (rank == 1) { 21 | result2 = 3; 22 | #pragma omp flush (result2) 23 | dummy = result2; 24 | } 25 | if (rank == 0) { 26 | my_sleep(SLEEPTIME); 27 | #pragma omp flush (result2) 28 | result1 = result2; 29 | } 30 | } /* end of parallel */ 31 | return ((result1 == result2) && (result2 == dummy) && (result2 == 3)); 32 | } 33 | 34 | int main() 35 | { 36 | int i; 37 | int num_failed=0; 38 | 39 | // the test requires more than 1 thread to pass 40 | omp_set_dynamic(0); // disable dynamic adjustment of threads 41 | if (omp_get_max_threads() == 1) 42 | omp_set_num_threads(2); // set 2 threads if no HW resources available 43 | 44 | for (i = 0; i < REPETITIONS; i++) { 45 | if(!test_omp_flush()) { 46 | num_failed++; 47 | } 48 | } 49 | return num_failed; 50 | } 51 | -------------------------------------------------------------------------------- /runtime/test/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @AUTO_GEN_COMMENT@ 2 | 3 | config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" 4 | config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" 5 | config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ 6 | config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" 7 | config.test_not = "@OPENMP_NOT_EXECUTABLE@" 8 | config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" 9 | config.test_extra_flags = "@OPENMP_TEST_FLAGS@" 10 | config.libomp_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" 11 | config.library_dir = "@LIBBOLT_LIBRARY_DIR@" 12 | config.omp_header_directory = "@LIBOMP_BINARY_DIR@/src" 13 | config.operating_system = "@CMAKE_SYSTEM_NAME@" 14 | config.hwloc_library_dir = "@LIBOMP_HWLOC_LIBRARY_DIR@" 15 | config.using_hwloc = @LIBOMP_USE_HWLOC@ 16 | config.using_abt = @LIBOMP_TEST_USE_ARGOBOTS@ 17 | config.has_ompt = @LIBBOLT_OMPT_SUPPORT@ and @LIBOMP_OMPT_OPTIONAL@ 18 | config.has_libm = @LIBOMP_HAVE_LIBM@ 19 | config.has_libatomic = @LIBOMP_HAVE_LIBATOMIC@ 20 | 21 | # Let the main config do the real work. 22 | lit_config.load_config(config, "@LIBOMP_BASE_DIR@/test/lit.cfg") 23 | -------------------------------------------------------------------------------- /runtime/test/lock/omp_lock.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // RUN: env KMP_LOCK_KIND=tas KMP_SPIN_BACKOFF_PARAMS=2048,200 %libomp-run 3 | // RUN: env KMP_LOCK_KIND=futex %libomp-run 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | omp_lock_t lck; 8 | 9 | int test_omp_lock() 10 | { 11 | int nr_threads_in_single = 0; 12 | int result = 0; 13 | int nr_iterations = 0; 14 | int i; 15 | 16 | omp_init_lock(&lck); 17 | #pragma omp parallel shared(lck) 18 | { 19 | #pragma omp for 20 | for(i = 0; i < LOOPCOUNT; i++) { 21 | omp_set_lock(&lck); 22 | #pragma omp flush 23 | nr_threads_in_single++; 24 | #pragma omp flush 25 | nr_iterations++; 26 | nr_threads_in_single--; 27 | result = result + nr_threads_in_single; 28 | omp_unset_lock(&lck); 29 | } 30 | } 31 | omp_destroy_lock(&lck); 32 | 33 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 34 | } 35 | 36 | int main() 37 | { 38 | int i; 39 | int num_failed=0; 40 | 41 | for(i = 0; i < REPETITIONS; i++) { 42 | if(!test_omp_lock()) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/lock/omp_nest_lock.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | omp_nest_lock_t lck; 6 | 7 | int test_omp_nest_lock() 8 | { 9 | int nr_threads_in_single = 0; 10 | int result = 0; 11 | int nr_iterations = 0; 12 | int i; 13 | 14 | omp_init_nest_lock(&lck); 15 | #pragma omp parallel shared(lck) 16 | { 17 | #pragma omp for 18 | for(i = 0; i < LOOPCOUNT; i++) { 19 | omp_set_nest_lock(&lck); 20 | #pragma omp flush 21 | nr_threads_in_single++; 22 | #pragma omp flush 23 | nr_iterations++; 24 | nr_threads_in_single--; 25 | result = result + nr_threads_in_single; 26 | omp_unset_nest_lock(&lck); 27 | } 28 | } 29 | omp_destroy_nest_lock(&lck); 30 | 31 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 32 | } 33 | 34 | int main() 35 | { 36 | int i; 37 | int num_failed=0; 38 | 39 | for(i = 0; i < REPETITIONS; i++) { 40 | if(!test_omp_nest_lock()) { 41 | num_failed++; 42 | } 43 | } 44 | return num_failed; 45 | } 46 | -------------------------------------------------------------------------------- /runtime/test/lock/omp_test_lock.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // RUN: env KMP_LOCK_KIND=tas %libomp-run 3 | // RUN: env KMP_LOCK_KIND=futex %libomp-run 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | omp_lock_t lck; 8 | 9 | int test_omp_test_lock() 10 | { 11 | int nr_threads_in_single = 0; 12 | int result = 0; 13 | int nr_iterations = 0; 14 | int i; 15 | 16 | omp_init_lock (&lck); 17 | #pragma omp parallel shared(lck) 18 | { 19 | #pragma omp for 20 | for (i = 0; i < LOOPCOUNT; i++) { 21 | while (!omp_test_lock (&lck)) 22 | {}; 23 | #pragma omp flush 24 | nr_threads_in_single++; 25 | #pragma omp flush 26 | nr_iterations++; 27 | nr_threads_in_single--; 28 | result = result + nr_threads_in_single; 29 | omp_unset_lock (&lck); 30 | } 31 | } 32 | omp_destroy_lock(&lck); 33 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 34 | } 35 | 36 | int main() 37 | { 38 | int i; 39 | int num_failed=0; 40 | 41 | for(i = 0; i < REPETITIONS; i++) { 42 | if(!test_omp_test_lock()) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/lock/omp_test_nest_lock.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | static omp_nest_lock_t lck; 6 | 7 | int test_omp_test_nest_lock() 8 | { 9 | int nr_threads_in_single = 0; 10 | int result = 0; 11 | int nr_iterations = 0; 12 | int i; 13 | 14 | omp_init_nest_lock (&lck); 15 | #pragma omp parallel shared(lck) 16 | { 17 | #pragma omp for 18 | for (i = 0; i < LOOPCOUNT; i++) 19 | { 20 | /*omp_set_lock(&lck);*/ 21 | while(!omp_test_nest_lock (&lck)) 22 | {}; 23 | #pragma omp flush 24 | nr_threads_in_single++; 25 | #pragma omp flush 26 | nr_iterations++; 27 | nr_threads_in_single--; 28 | result = result + nr_threads_in_single; 29 | omp_unset_nest_lock (&lck); 30 | } 31 | } 32 | omp_destroy_nest_lock (&lck); 33 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 34 | } 35 | 36 | int main() 37 | { 38 | int i; 39 | int num_failed=0; 40 | 41 | for(i = 0; i < REPETITIONS; i++) { 42 | if(!test_omp_test_nest_lock()) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/master/omp_master.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_master() 6 | { 7 | int nthreads; 8 | int executing_thread; 9 | 10 | nthreads = 0; 11 | executing_thread = -1; 12 | 13 | #pragma omp parallel 14 | { 15 | #pragma omp master 16 | { 17 | #pragma omp critical 18 | { 19 | nthreads++; 20 | } 21 | executing_thread = omp_get_thread_num(); 22 | } /* end of master*/ 23 | } /* end of parallel*/ 24 | return ((nthreads == 1) && (executing_thread == 0)); 25 | } 26 | 27 | int main() 28 | { 29 | int i; 30 | int num_failed=0; 31 | 32 | for(i = 0; i < REPETITIONS; i++) { 33 | if(!test_omp_master()) { 34 | num_failed++; 35 | } 36 | } 37 | return num_failed; 38 | } 39 | -------------------------------------------------------------------------------- /runtime/test/master/omp_master_3.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_master_3() 6 | { 7 | int nthreads; 8 | int executing_thread; 9 | int tid_result = 0; /* counts up the number of wrong thread no. for 10 | the master thread. (Must be 0) */ 11 | nthreads = 0; 12 | executing_thread = -1; 13 | 14 | #pragma omp parallel 15 | { 16 | #pragma omp master 17 | { 18 | int tid = omp_get_thread_num(); 19 | if (tid != 0) { 20 | #pragma omp critical 21 | { tid_result++; } 22 | } 23 | #pragma omp critical 24 | { 25 | nthreads++; 26 | } 27 | executing_thread = omp_get_thread_num (); 28 | } /* end of master*/ 29 | } /* end of parallel*/ 30 | return ((nthreads == 1) && (executing_thread == 0) && (tid_result == 0)); 31 | } 32 | 33 | int main() 34 | { 35 | int i; 36 | int num_failed=0; 37 | 38 | for(i = 0; i < REPETITIONS; i++) { 39 | if(!test_omp_master_3()) { 40 | num_failed++; 41 | } 42 | } 43 | return num_failed; 44 | } 45 | -------------------------------------------------------------------------------- /runtime/test/misc_bugs/many-microtask-args.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | 4 | int main() 5 | { 6 | 7 | int i; 8 | int i1 = 0; 9 | int i2 = 1; 10 | int i3 = 2; 11 | int i4 = 3; 12 | int i5 = 4; 13 | int i6 = 6; 14 | int i7 = 7; 15 | int i8 = 8; 16 | int i9 = 9; 17 | int i10 = 10; 18 | int i11 = 11; 19 | int i12 = 12; 20 | int i13 = 13; 21 | int i14 = 14; 22 | int i15 = 15; 23 | int i16 = 16; 24 | 25 | int r = 0; 26 | #pragma omp parallel for firstprivate(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16) reduction(+:r) 27 | for (i = 0; i < i16; i++) { 28 | r += i + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + i13 + i14 + i15 + i16; 29 | } 30 | 31 | int rf = 2216; 32 | if (r != rf) { 33 | fprintf(stderr, "r should be %d but instead equals %d\n", rf, r); 34 | return 1; 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /runtime/test/omp_my_sleep.h: -------------------------------------------------------------------------------- 1 | #ifndef MY_SLEEP_H 2 | #define MY_SLEEP_H 3 | 4 | /*! Utility function to have a sleep function with better resolution and 5 | * which only stops one thread. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #if defined(_WIN32) 13 | # include 14 | // Windows version of my_sleep() function 15 | static void my_sleep(double sleeptime) { 16 | DWORD ms = (DWORD) (sleeptime * 1000.0); 17 | Sleep(ms); 18 | } 19 | 20 | 21 | #else // _WIN32 22 | 23 | // Unices version of my_sleep() function 24 | static void my_sleep(double sleeptime) { 25 | struct timespec ts; 26 | ts.tv_sec = (time_t)sleeptime; 27 | ts.tv_nsec = (long)((sleeptime - (double)ts.tv_sec) * 1E9); 28 | nanosleep(&ts, NULL); 29 | } 30 | 31 | #endif // _WIN32 32 | 33 | #endif // MY_SLEEP_H 34 | -------------------------------------------------------------------------------- /runtime/test/ompt/misc/control_tool.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 4 | #define TEST_NEED_PRINT_FRAME_FROM_OUTLINED_FN 5 | #include "callback.h" 6 | #include 7 | 8 | int main() 9 | { 10 | #pragma omp parallel num_threads(1) 11 | { 12 | print_frame_from_outlined_fn(1); 13 | print_frame(0); 14 | omp_control_tool(omp_control_tool_flush, 1, NULL); 15 | print_current_address(0); 16 | } 17 | 18 | // Check if libomp supports the callbacks for this test. 19 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_control_tool' 20 | 21 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 22 | 23 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: __builtin_frame_address({{.}})=[[EXIT_FRAME:0x[0-f]*]] 24 | // CHECK: {{^}}[[MASTER_ID]]: __builtin_frame_address(0)=[[REENTER_FRAME:0x[0-f]*]] 25 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_control_tool: command=3, modifier=1, arg=[[NULL]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]*]], current_task_frame.exit=[[EXIT_FRAME]], current_task_frame.reenter={{0x[0-f]*}} 26 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /runtime/test/ompt/misc/control_tool_no_ompt_support.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | #pragma omp parallel num_threads(1) 8 | { 9 | omp_control_tool(omp_control_tool_flush, 1, NULL); 10 | } 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /runtime/test/ompt/misc/finalize_tool.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | #include "callback.h" 4 | 5 | int main() { 6 | #pragma omp parallel num_threads(2) 7 | {} 8 | 9 | printf("Before ompt_finalize_tool\n"); 10 | ompt_finalize_tool(); 11 | printf("After ompt_finalize_tool\n"); 12 | 13 | return 0; 14 | } 15 | 16 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 17 | // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin: 18 | // CHECK-SAME: thread_type=ompt_thread_initial=1 19 | 20 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_begin 21 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end 22 | 23 | // CHECK: {{^}}Before ompt_finalize_tool 24 | 25 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_thread_end: thread_id=[[THREAD_ID]] 26 | // CHECK: 0: ompt_event_runtime_shutdown 27 | 28 | // CHECK: {{^}}After ompt_finalize_tool 29 | -------------------------------------------------------------------------------- /runtime/test/ompt/misc/threads.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s 2 | // REQUIRES: ompt 3 | #include "callback.h" 4 | #include 5 | 6 | int main() { 7 | int x = 0; 8 | #pragma omp parallel num_threads(4) 9 | { 10 | #pragma omp atomic 11 | x++; 12 | } 13 | 14 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 15 | 16 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_thread_begin: 17 | // CHECK-SAME: thread_type=ompt_thread_initial=1, thread_id=[[MASTER_ID]] 18 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_thread_end: 19 | // CHECK-SAME: thread_id=[[MASTER_ID]] 20 | // CHECK: {{^}}[[WORKER_ID1:[0-9]+]]: ompt_event_thread_begin: 21 | // CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[WORKER_ID1]] 22 | // CHECK: {{^}}[[WORKER_ID1]]: ompt_event_thread_end: 23 | // CHECK-SAME: thread_id=[[WORKER_ID1]] 24 | // CHECK: {{^}}[[WORKER_ID2:[0-9]+]]: ompt_event_thread_begin: 25 | // CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[WORKER_ID2]] 26 | // CHECK: {{^}}[[WORKER_ID2]]: ompt_event_thread_end: 27 | // CHECK-SAME: thread_id=[[WORKER_ID2]] 28 | // CHECK: {{^}}[[WORKER_ID3:[0-9]+]]: ompt_event_thread_begin: 29 | // CHECK-SAME: thread_type=ompt_thread_worker=2, thread_id=[[WORKER_ID3]] 30 | // CHECK: {{^}}[[WORKER_ID3]]: ompt_event_thread_end: 31 | // CHECK-SAME: thread_id=[[WORKER_ID3]] 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /runtime/test/ompt/misc/unset_callback.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | #include "callback.h" 4 | #include 5 | 6 | int main() 7 | { 8 | #pragma omp parallel num_threads(1) 9 | { 10 | 11 | } 12 | ompt_set_callback(ompt_callback_parallel_begin, NULL); 13 | #pragma omp parallel num_threads(1) 14 | { 15 | 16 | } 17 | 18 | // Check if libomp supports the callbacks for this test. 19 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_idle' 20 | 21 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 22 | 23 | // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_parallel_begin: 24 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end: 25 | // CHECK-NOT: {{^}}[[THREAD_ID]]: ompt_event_parallel_begin: 26 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end: 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /runtime/test/ompt/ompt-signal.h: -------------------------------------------------------------------------------- 1 | #if defined(WIN32) || defined(_WIN32) 2 | #include 3 | #define delay() Sleep(1); 4 | #else 5 | #include 6 | #define delay(t) usleep(t); 7 | #endif 8 | 9 | // These functions are used to provide a signal-wait mechanism to enforce expected scheduling for the test cases. 10 | // Conditional variable (s) needs to be shared! Initialize to 0 11 | 12 | #define OMPT_SIGNAL(s) ompt_signal(&s) 13 | //inline 14 | void ompt_signal(int* s) 15 | { 16 | #pragma omp atomic 17 | (*s)++; 18 | } 19 | 20 | #define OMPT_WAIT(s,v) ompt_wait(&s,v) 21 | // wait for s >= v 22 | //inline 23 | void ompt_wait(int *s, int v) 24 | { 25 | int wait=0; 26 | do{ 27 | delay(10); 28 | #pragma omp atomic read 29 | wait = (*s); 30 | }while(wait 7 | 8 | int main() 9 | { 10 | int y[] = {0,1,2,3}; 11 | 12 | int i; 13 | #pragma omp for simd 14 | for (i = 0; i < 4; i++) 15 | { 16 | y[i]++; 17 | } 18 | 19 | 20 | // Check if libomp supports the callbacks for this test. 21 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_sync_region' 22 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_sync_region_wait' 23 | 24 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 25 | 26 | // master thread implicit barrier at simd loop end 27 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_barrier_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, codeptr_ra={{0x[0-f]+}} 28 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_wait_barrier_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, codeptr_ra={{0x[0-f]+}} 29 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_wait_barrier_end: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, codeptr_ra={{0x[0-f]+}} 30 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_barrier_end: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, codeptr_ra={{0x[0-f]+}} 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /runtime/test/ompt/synchronization/critical.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 4 | #include "callback.h" 5 | #include 6 | 7 | int main() 8 | { 9 | #pragma omp critical 10 | { 11 | print_current_address(1); 12 | print_ids(0); 13 | } 14 | print_current_address(2); 15 | 16 | 17 | // Check if libomp supports the callbacks for this test. 18 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquire' 19 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquired' 20 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_released' 21 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_nest_lock' 22 | 23 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 24 | 25 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_wait_critical: wait_id=[[WAIT_ID:[0-9]+]], hint={{[0-9]+}}, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 26 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_acquired_critical: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS]] 27 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 28 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_release_critical: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 29 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/ompt/synchronization/flush.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s 2 | // REQUIRES: ompt 3 | // GCC generates code that does not call the runtime for the flush construct 4 | // XFAIL: gcc 5 | 6 | #include "callback.h" 7 | #include 8 | 9 | int main() { 10 | #pragma omp parallel num_threads(2) 11 | { 12 | int tid = omp_get_thread_num(); 13 | 14 | #pragma omp flush 15 | print_current_address(1); 16 | } 17 | 18 | return 0; 19 | } 20 | // Check if libomp supports the callbacks for this test. 21 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_flush' 22 | 23 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 24 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_flush: 25 | // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 26 | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 27 | // 28 | // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_flush: 29 | // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 30 | // CHECK: {{^}}[[THREAD_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 31 | -------------------------------------------------------------------------------- /runtime/test/ompt/synchronization/masked.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | // GCC generates code that does not call the runtime for the master construct 4 | // XFAIL: gcc 5 | 6 | #include "callback.h" 7 | #include 8 | 9 | int main() { 10 | int x = 0; 11 | #pragma omp parallel num_threads(2) 12 | { 13 | #pragma omp master 14 | { 15 | print_fuzzy_address(1); 16 | x++; 17 | } 18 | print_current_address(2); 19 | } 20 | 21 | printf("%" PRIu64 ": x=%d\n", ompt_get_thread_data()->value, x); 22 | 23 | return 0; 24 | } 25 | 26 | // Check if libomp supports the callbacks for this test. 27 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked' 28 | 29 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 30 | 31 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin: 32 | // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[TASK_ID:[0-9]+]], 33 | // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}} 34 | // CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]] 35 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_masked_end: 36 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]], 37 | // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS_END:0x[0-f]+]] 38 | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]] 39 | -------------------------------------------------------------------------------- /runtime/test/ompt/synchronization/ordered.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // REQUIRES: ompt 3 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 4 | #include "callback.h" 5 | #include 6 | 7 | int main() 8 | { 9 | #pragma omp ordered 10 | { 11 | print_current_address(1); 12 | print_ids(0); 13 | } 14 | print_current_address(2); 15 | 16 | 17 | // Check if libomp supports the callbacks for this test. 18 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquire' 19 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquired' 20 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_released' 21 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_nest_lock' 22 | 23 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 24 | 25 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_wait_ordered: wait_id=[[WAIT_ID:[0-9]+]], hint={{[0-9]+}}, impl={{[0-9]+}}, codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 26 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_acquired_ordered: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS]] 27 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 28 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_release_ordered: wait_id=[[WAIT_ID]], codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]] 29 | // CHECK-NEXT: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS]] 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/ompt/synchronization/reduction/empty_reduce.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | FileCheck %s 2 | // RUN: %libomp-compile -DNOWAIT && %libomp-run | FileCheck %s 3 | // REQUIRES: ompt 4 | // UNSUPPORTED: gcc 5 | #include "callback.h" 6 | #include 7 | 8 | #ifdef NOWAIT 9 | #define FOR_CLAUSE nowait 10 | #else 11 | #define FOR_CLAUSE 12 | #endif 13 | 14 | int main() { 15 | int sum = 0; 16 | int i; 17 | #pragma omp parallel num_threads(1) 18 | #pragma omp for reduction(+ : sum) FOR_CLAUSE 19 | for (i = 0; i < 10000; i++) { 20 | sum += i; 21 | } 22 | 23 | // CHECK: 0: NULL_POINTER=[[NULL:.*$]] 24 | 25 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin: 26 | // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]] 27 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: 28 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID:[0-9]+]] 29 | 30 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_reduction_begin: 31 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]], 32 | // CHECK-SAME: codeptr_ra= 33 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_reduction_end: 34 | // CHECK-SAME: parallel_id=[[PARALLEL_ID]], 35 | // CHECK-SAME: task_id=[[TASK_ID]], codeptr_ra= 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/auto.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h 2 | // REQUIRES: ompt 3 | // GCC doesn't call runtime for auto = static schedule 4 | // XFAIL: gcc 5 | 6 | #define SCHEDULE auto 7 | #include "base.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/auto_serialized.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h 2 | // REQUIRES: ompt 3 | // GCC doesn't call runtime for auto = static schedule 4 | // XFAIL: gcc 5 | 6 | #define SCHEDULE auto 7 | #include "base_serialized.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/auto_split.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_split.h 2 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=CHECK-LOOP %S/base_split.h 3 | // REQUIRES: ompt 4 | // GCC doesn't call runtime for auto = static schedule 5 | // XFAIL: gcc 6 | 7 | #define SCHEDULE auto 8 | #include "base_split.h" 9 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/dynamic.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE dynamic 5 | #include "base.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/dynamic_serialized.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE dynamic 5 | #include "base_serialized.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/dynamic_split.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_split.h 2 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=CHECK-LOOP %S/base_split.h 3 | // REQUIRES: ompt 4 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 5 | 6 | #define SCHEDULE dynamic 7 | #include "base_split.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/guided.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE guided 5 | #include "base.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/guided_serialized.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE guided 5 | #include "base_serialized.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/guided_split.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_split.h 2 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=CHECK-LOOP %S/base_split.h 3 | // REQUIRES: ompt 4 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 5 | 6 | #define SCHEDULE guided 7 | #include "base_split.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/runtime.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE runtime 5 | #include "base.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/runtime_serialized.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h 2 | // REQUIRES: ompt 3 | 4 | #define SCHEDULE runtime 5 | #include "base_serialized.h" 6 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/runtime_split.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_split.h 2 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=CHECK-LOOP %S/base_split.h 3 | // REQUIRES: ompt 4 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7 5 | 6 | #define SCHEDULE runtime 7 | #include "base_split.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/static.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h 2 | // REQUIRES: ompt 3 | // GCC doesn't call runtime for static schedule 4 | // XFAIL: gcc 5 | 6 | #define SCHEDULE static 7 | #include "base.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/static_serialized.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h 2 | // REQUIRES: ompt 3 | // GCC doesn't call runtime for static schedule 4 | // XFAIL: gcc 5 | 6 | #define SCHEDULE static 7 | #include "base_serialized.h" 8 | -------------------------------------------------------------------------------- /runtime/test/ompt/worksharing/for/static_split.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_split.h 2 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck --check-prefix=CHECK-LOOP %S/base_split.h 3 | // REQUIRES: ompt 4 | // GCC doesn't call runtime for static schedule 5 | // XFAIL: gcc 6 | 7 | #define SCHEDULE static 8 | #include "base_split.h" 9 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_nested.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | /* 6 | * Test if the compiler supports nested parallelism 7 | * By Chunhua Liao, University of Houston 8 | * Oct. 2005 9 | */ 10 | int test_omp_nested() 11 | { 12 | #ifdef _OPENMP 13 | if (omp_get_max_threads() > 4) 14 | omp_set_num_threads(4); 15 | if (omp_get_max_threads() < 2) 16 | omp_set_num_threads(2); 17 | #endif 18 | 19 | int counter = 0; 20 | #ifdef _OPENMP 21 | omp_set_nested(1); 22 | omp_set_max_active_levels(omp_get_supported_active_levels()); 23 | #endif 24 | 25 | #pragma omp parallel shared(counter) 26 | { 27 | #pragma omp critical 28 | counter++; 29 | #pragma omp parallel 30 | { 31 | #pragma omp critical 32 | counter--; 33 | } 34 | } 35 | return (counter != 0); 36 | } 37 | 38 | int main() 39 | { 40 | int i; 41 | int num_failed=0; 42 | 43 | for(i = 0; i < REPETITIONS; i++) { 44 | if(!test_omp_nested()) { 45 | num_failed++; 46 | } 47 | } 48 | return num_failed; 49 | } 50 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_copyin.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: !(abt && (clang || gcc)) 3 | #include 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | static int sum1 = 789; 8 | #pragma omp threadprivate(sum1) 9 | 10 | int test_omp_parallel_copyin() 11 | { 12 | int sum, num_threads; 13 | int known_sum; 14 | 15 | sum = 0; 16 | sum1 = 7; 17 | num_threads = 0; 18 | 19 | #pragma omp parallel copyin(sum1) 20 | { 21 | /*printf("sum1=%d\n",sum1);*/ 22 | int i; 23 | #pragma omp for 24 | for (i = 1; i < 1000; i++) { 25 | sum1 = sum1 + i; 26 | } /*end of for*/ 27 | #pragma omp critical 28 | { 29 | sum = sum + sum1; 30 | num_threads++; 31 | } /*end of critical*/ 32 | } /* end of parallel*/ 33 | known_sum = (999 * 1000) / 2 + 7 * num_threads; 34 | return (known_sum == sum); 35 | } 36 | 37 | int main() 38 | { 39 | int i; 40 | int num_failed=0; 41 | 42 | for(i = 0; i < REPETITIONS; i++) { 43 | if(!test_omp_parallel_copyin()) { 44 | num_failed++; 45 | } 46 | } 47 | return num_failed; 48 | } 49 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_default.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_default() 6 | { 7 | int i; 8 | int sum; 9 | int mysum; 10 | int known_sum; 11 | sum =0; 12 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ; 13 | 14 | #pragma omp parallel default(shared) private(i) private(mysum) 15 | { 16 | mysum = 0; 17 | #pragma omp for 18 | for (i = 1; i <= LOOPCOUNT; i++) { 19 | mysum = mysum + i; 20 | } 21 | #pragma omp critical 22 | { 23 | sum = sum + mysum; 24 | } /* end of critical */ 25 | } /* end of parallel */ 26 | if (known_sum != sum) { 27 | fprintf(stderr, "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum); 28 | } 29 | return (known_sum == sum); 30 | } 31 | 32 | int main() 33 | { 34 | int i; 35 | int num_failed=0; 36 | 37 | for(i = 0; i < REPETITIONS; i++) { 38 | if(!test_omp_parallel_default()) { 39 | num_failed++; 40 | } 41 | } 42 | return num_failed; 43 | } 44 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | //static int sum1 = 789; 7 | 8 | int test_omp_parallel_firstprivate() 9 | { 10 | int sum, num_threads,sum1; 11 | int known_sum; 12 | 13 | sum = 0; 14 | sum1=7; 15 | num_threads = 0; 16 | 17 | #pragma omp parallel firstprivate(sum1) 18 | { 19 | /*printf("sum1=%d\n",sum1);*/ 20 | int i; 21 | #pragma omp for 22 | for (i = 1; i < 1000; i++) { 23 | sum1 = sum1 + i; 24 | } /*end of for*/ 25 | #pragma omp critical 26 | { 27 | sum = sum + sum1; 28 | num_threads++; 29 | } /*end of critical*/ 30 | } /* end of parallel*/ 31 | known_sum = (999 * 1000) / 2 + 7 * num_threads; 32 | return (known_sum == sum); 33 | } 34 | 35 | int main() 36 | { 37 | int i; 38 | int num_failed=0; 39 | 40 | for(i = 0; i < REPETITIONS; i++) { 41 | if(!test_omp_parallel_firstprivate()) { 42 | num_failed++; 43 | } 44 | } 45 | return num_failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_if.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_if() 6 | { 7 | int i; 8 | int sum; 9 | int known_sum; 10 | int mysum; 11 | int control=1; 12 | 13 | sum =0; 14 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ; 15 | #pragma omp parallel private(i) if(control==0) 16 | { 17 | mysum = 0; 18 | for (i = 1; i <= LOOPCOUNT; i++) { 19 | mysum = mysum + i; 20 | } 21 | #pragma omp critical 22 | { 23 | sum = sum + mysum; 24 | } 25 | } 26 | return (known_sum == sum); 27 | } 28 | 29 | int main() 30 | { 31 | int i; 32 | int num_failed=0; 33 | 34 | for(i = 0; i < REPETITIONS; i++) { 35 | if(!test_omp_parallel_if()) { 36 | num_failed++; 37 | } 38 | } 39 | return num_failed; 40 | } 41 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_num_threads.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_num_threads() 6 | { 7 | int num_failed; 8 | int threads; 9 | int nthreads; 10 | int max_threads = 0; 11 | 12 | num_failed = 0; 13 | 14 | /* first we check how many threads are available */ 15 | #pragma omp parallel 16 | { 17 | #pragma omp master 18 | max_threads = omp_get_num_threads (); 19 | } 20 | 21 | /* we increase the number of threads from one to maximum:*/ 22 | for(threads = 1; threads <= max_threads; threads++) { 23 | nthreads = 0; 24 | #pragma omp parallel reduction(+:num_failed) num_threads(threads) 25 | { 26 | num_failed = num_failed + !(threads == omp_get_num_threads()); 27 | #pragma omp atomic 28 | nthreads += 1; 29 | } 30 | num_failed = num_failed + !(nthreads == threads); 31 | } 32 | return (!num_failed); 33 | } 34 | 35 | int main() 36 | { 37 | int i; 38 | int num_failed=0; 39 | 40 | for(i = 0; i < REPETITIONS; i++) { 41 | if(!test_omp_parallel_num_threads()) { 42 | num_failed++; 43 | } 44 | } 45 | return num_failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_private.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | //static int sum1 = 789; 7 | 8 | int test_omp_parallel_private() 9 | { 10 | int sum, num_threads,sum1; 11 | int known_sum; 12 | 13 | sum = 0; 14 | num_threads = 0; 15 | 16 | #pragma omp parallel private(sum1) 17 | { 18 | int i; 19 | sum1 = 7; 20 | /*printf("sum1=%d\n",sum1);*/ 21 | #pragma omp for 22 | for (i = 1; i < 1000; i++) { 23 | sum1 = sum1 + i; 24 | } 25 | #pragma omp critical 26 | { 27 | sum = sum + sum1; 28 | num_threads++; 29 | } 30 | } 31 | known_sum = (999 * 1000) / 2 + 7 * num_threads; 32 | return (known_sum == sum); 33 | } 34 | 35 | int main() 36 | { 37 | int i; 38 | int num_failed=0; 39 | 40 | for(i = 0; i < REPETITIONS; i++) { 41 | if(!test_omp_parallel_private()) { 42 | num_failed++; 43 | } 44 | } 45 | return num_failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/parallel/omp_parallel_shared.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_shared() 6 | { 7 | int i; 8 | int sum; 9 | int known_sum; 10 | 11 | sum = 0; 12 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ; 13 | 14 | #pragma omp parallel private(i) shared(sum) 15 | { 16 | 17 | int mysum = 0; 18 | #pragma omp for 19 | for (i = 1; i <= LOOPCOUNT; i++) { 20 | mysum = mysum + i; 21 | } 22 | #pragma omp critical 23 | { 24 | sum = sum + mysum; 25 | } 26 | 27 | 28 | } 29 | if (known_sum != sum) { 30 | fprintf(stderr, "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum); 31 | } 32 | return (known_sum == sum); 33 | } 34 | 35 | int main() 36 | { 37 | int i; 38 | int num_failed=0; 39 | 40 | for(i = 0; i < REPETITIONS; i++) { 41 | if(!test_omp_parallel_shared()) { 42 | num_failed++; 43 | } 44 | } 45 | return num_failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/tasking/bug_36720.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | /* 4 | Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=36720 5 | 6 | Assertion failure at kmp_runtime.cpp(1715): nthreads > 0. 7 | OMP: Error #13: Assertion failure at kmp_runtime.cpp(1715). 8 | 9 | The assertion fails even with OMP_NUM_THREADS=1. If the second task is removed, 10 | everything runs to completion. If the "omp parallel for" directives are removed 11 | from inside the tasks, once again everything runs fine. 12 | */ 13 | 14 | #define N 1024 15 | 16 | int main() { 17 | #pragma omp task 18 | { 19 | int i; 20 | #pragma omp parallel for 21 | for (i = 0; i < N; i++) 22 | (void)0; 23 | } 24 | 25 | #pragma omp task 26 | { 27 | int i; 28 | #pragma omp parallel for 29 | for (i = 0; i < N; ++i) 30 | (void)0; 31 | } 32 | 33 | #pragma omp taskwait 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /runtime/test/tasking/bug_serial_taskgroup.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | /* 4 | GCC failed this test because __kmp_get_gtid() instead of __kmp_entry_gtid() 5 | was called in xexpand(KMP_API_NAME_GOMP_TASKGROUP_START)(void). 6 | __kmp_entry_gtid() will initialize the runtime if not yet done which does not 7 | happen with __kmp_get_gtid(). 8 | */ 9 | 10 | int main() 11 | { 12 | #pragma omp taskgroup 13 | { } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /runtime/test/tasking/nested_parallel_tasking.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | 5 | /* 6 | * This test would hang when level instead of active level 7 | * used to push task state. 8 | */ 9 | 10 | int main() 11 | { 12 | // If num_threads is changed to a value greater than 1, then the test passes 13 | #pragma omp parallel num_threads(1) 14 | { 15 | #pragma omp parallel 16 | printf("Hello World from thread %d\n", omp_get_thread_num()); 17 | } 18 | 19 | printf("omp_num_threads: %d\n", omp_get_max_threads()); 20 | 21 | #pragma omp parallel 22 | { 23 | #pragma omp master 24 | #pragma omp task default(none) 25 | { 26 | printf("%d is executing this task\n", omp_get_thread_num()); 27 | } 28 | } 29 | 30 | printf("pass\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /runtime/test/tasking/nested_task_creation.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_my_sleep.h" 5 | 6 | /* 7 | * This test creates tasks that themselves create a new task. 8 | * The runtime has to take care that they are correctly freed. 9 | */ 10 | 11 | int main() 12 | { 13 | #pragma omp task 14 | { 15 | #pragma omp task 16 | { 17 | my_sleep( 0.1 ); 18 | } 19 | } 20 | 21 | #pragma omp parallel num_threads(2) 22 | { 23 | #pragma omp single 24 | #pragma omp task 25 | { 26 | #pragma omp task 27 | { 28 | my_sleep( 0.1 ); 29 | } 30 | } 31 | } 32 | 33 | printf("pass\n"); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_detach_taskwait.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='3' %libomp-run 2 | // RUN: %libomp-compile -fopenmp-version=50 && env OMP_NUM_THREADS='1' %libomp-run 3 | 4 | // Checked gcc 10.1 still does not support detach clause on task construct. 5 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10 6 | // clang supports detach clause since version 11. 7 | // UNSUPPORTED: clang-10, clang-9, clang-8, clang-7 8 | // icc compiler does not support detach clause. 9 | // UNSUPPORTED: icc 10 | // REQUIRES: !abt 11 | 12 | #include 13 | 14 | int main() 15 | { 16 | #pragma omp parallel 17 | #pragma omp master 18 | { 19 | omp_event_handle_t event; 20 | #pragma omp task detach(event) 21 | { 22 | omp_fulfill_event(event); 23 | } 24 | #pragma omp taskwait 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_depend_resize_hashmap.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env KMP_ENABLE_TASK_THROTTLING=0 %libomp-run 2 | 3 | // This test is known to be fragile on NetBSD kernel at the moment, 4 | // https://bugs.llvm.org/show_bug.cgi?id=42020. 5 | // UNSUPPORTED: netbsd 6 | 7 | // Very flaky on openmp-clang-x86_64-linux-debian. 8 | // https://bugs.llvm.org/show_bug.cgi?id=45397 9 | // UNSUPPORTED: linux 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | // The first hashtable static size is 997 16 | #define NUM_DEPS 4000 17 | 18 | 19 | int main() 20 | { 21 | int *deps = calloc(NUM_DEPS, sizeof(int)); 22 | int i; 23 | int failed = 0; 24 | 25 | #pragma omp parallel 26 | #pragma omp master 27 | { 28 | for (i = 0; i < NUM_DEPS; i++) { 29 | #pragma omp task firstprivate(i) depend(inout: deps[i]) 30 | { 31 | deps[i] = 1; 32 | } 33 | #pragma omp task firstprivate(i) depend(inout: deps[i]) 34 | { 35 | deps[i] = 2; 36 | } 37 | } 38 | } 39 | 40 | for (i = 0; i < NUM_DEPS; i++) { 41 | if (deps[i] != 2) 42 | failed++; 43 | } 44 | 45 | return failed; 46 | } 47 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_omp_task_firstprivate() 7 | { 8 | int i; 9 | int sum = 1234; 10 | int known_sum; 11 | int result = 0; /* counts the wrong sums from tasks */ 12 | 13 | known_sum = 1234 + (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 14 | 15 | #pragma omp parallel 16 | { 17 | #pragma omp single 18 | { 19 | for (i = 0; i < NUM_TASKS; i++) { 20 | #pragma omp task firstprivate(sum) 21 | { 22 | int j; 23 | for (j = 0; j <= LOOPCOUNT; j++) { 24 | #pragma omp flush 25 | sum += j; 26 | } 27 | 28 | /* check if calculated sum was right */ 29 | if (sum != known_sum) { 30 | #pragma omp critical 31 | { result++; } 32 | } 33 | } /* omp task */ 34 | } /* for loop */ 35 | } /* omp single */ 36 | } /* omp parallel */ 37 | return (result == 0); 38 | } 39 | 40 | int main() 41 | { 42 | int i; 43 | int num_failed=0; 44 | 45 | for(i = 0; i < REPETITIONS; i++) { 46 | if(!test_omp_task_firstprivate()) { 47 | num_failed++; 48 | } 49 | } 50 | return num_failed; 51 | } 52 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_if.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | #include "omp_my_sleep.h" 6 | 7 | int test_omp_task_if() 8 | { 9 | int condition_false; 10 | int count; 11 | int result; 12 | 13 | count=0; 14 | condition_false = (count == 1); 15 | #pragma omp parallel 16 | { 17 | #pragma omp single 18 | { 19 | #pragma omp task if (condition_false) shared(count, result) 20 | { 21 | my_sleep (SLEEPTIME); 22 | #pragma omp critical 23 | result = (0 == count); 24 | } /* end of omp task */ 25 | #pragma omp critical 26 | count = 1; 27 | } /* end of single */ 28 | } /*end of parallel */ 29 | return result; 30 | } 31 | 32 | int main() 33 | { 34 | int i; 35 | int num_failed=0; 36 | 37 | for(i = 0; i < REPETITIONS; i++) { 38 | if(!test_omp_task_if()) { 39 | num_failed++; 40 | } 41 | } 42 | return num_failed; 43 | } 44 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_imp_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | /* Utility function do spend some time in a loop */ 7 | int test_omp_task_imp_firstprivate() 8 | { 9 | int i=5; 10 | int k = 0; 11 | int result = 0; 12 | int task_result = 1; 13 | #pragma omp parallel firstprivate(i) 14 | { 15 | #pragma omp single 16 | { 17 | for (k = 0; k < NUM_TASKS; k++) { 18 | #pragma omp task shared(result , task_result) 19 | { 20 | int j; 21 | //check if i is private 22 | if(i != 5) 23 | task_result = 0; 24 | for(j = 0; j < NUM_TASKS; j++) 25 | i++; 26 | //this should be firstprivate implicitly 27 | } 28 | } 29 | #pragma omp taskwait 30 | result = (task_result && i==5); 31 | } 32 | } 33 | return result; 34 | } 35 | 36 | int main() 37 | { 38 | int i; 39 | int num_failed=0; 40 | 41 | for(i = 0; i < REPETITIONS; i++) { 42 | if(!test_omp_task_imp_firstprivate()) { 43 | num_failed++; 44 | } 45 | } 46 | return num_failed; 47 | } 48 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_nest_tied.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int fib(int n) { 6 | int a, b; 7 | if (n < 2) { 8 | return n; 9 | } else { 10 | if(n < 4) { 11 | return fib(n - 1) + fib(n - 2); 12 | } else { 13 | #pragma omp task shared(a) 14 | { 15 | a = fib(n - 1); 16 | } 17 | #pragma omp task shared(b) 18 | { 19 | b = fib(n - 2); 20 | } 21 | #pragma omp taskwait 22 | return a + b; 23 | } 24 | } 25 | } 26 | 27 | int fib_seq(int n) { 28 | int a, b; 29 | if (n < 2) { 30 | return n; 31 | } else { 32 | a = fib_seq(n - 1); 33 | b = fib_seq(n - 2); 34 | return a + b; 35 | } 36 | } 37 | 38 | int main() { 39 | int i; 40 | int n = 20; 41 | int num_failed = 0; 42 | 43 | for(i = 0; i < REPETITIONS; i++) { 44 | int task_val = 0; 45 | int seq_val = fib_seq(n); 46 | #pragma omp parallel shared(task_val) firstprivate(n) 47 | #pragma omp master 48 | { 49 | task_val = fib(n); 50 | } 51 | if(seq_val != task_val) { 52 | printf("[%d] Failed: fib(%d) = %d (ANS = %d)\n", i, n, task_val, seq_val); 53 | num_failed++; 54 | } 55 | } 56 | return num_failed; 57 | } 58 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_nest_untied.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int fib(int n) { 6 | int a, b; 7 | if (n < 2) { 8 | return n; 9 | } else { 10 | if(n < 4) { 11 | return fib(n - 1) + fib(n - 2); 12 | } else { 13 | #pragma omp task shared(a) untied 14 | { 15 | a = fib(n - 1); 16 | } 17 | #pragma omp task shared(b) untied 18 | { 19 | b = fib(n - 2); 20 | } 21 | #pragma omp taskwait 22 | return a + b; 23 | } 24 | } 25 | } 26 | 27 | int fib_seq(int n) { 28 | int a, b; 29 | if (n < 2) { 30 | return n; 31 | } else { 32 | a = fib_seq(n - 1); 33 | b = fib_seq(n - 2); 34 | return a + b; 35 | } 36 | } 37 | 38 | int main() { 39 | int i; 40 | int n = 20; 41 | int num_failed = 0; 42 | 43 | for(i = 0; i < REPETITIONS; i++) { 44 | int task_val = 0; 45 | int seq_val = fib_seq(n); 46 | #pragma omp parallel shared(task_val) firstprivate(n) 47 | #pragma omp master 48 | { 49 | task_val = fib(n); 50 | } 51 | if(seq_val != task_val) { 52 | printf("[%d] Failed: fib(%d) = %d (ANS = %d)\n", i, n, task_val, seq_val); 53 | num_failed++; 54 | } 55 | } 56 | return num_failed; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_priority.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile && env OMP_MAX_TASK_PRIORITY=42 %libomp-run 2 | // Test OMP 4.5 task priorities 3 | // Currently only API function and envirable parsing implemented. 4 | // Test environment sets envirable: OMP_MAX_TASK_PRIORITY=42 as tested below. 5 | #include 6 | #include 7 | 8 | int main (void) { 9 | int passed; 10 | 11 | passed = (omp_get_max_task_priority() == 42); 12 | printf("Got %d\n", omp_get_max_task_priority()); 13 | 14 | if (passed) { 15 | printf("passed\n"); 16 | return 0; 17 | } 18 | 19 | printf("failed\n"); 20 | return 1; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_private.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | /* Utility function do spend some time in a loop */ 7 | int test_omp_task_private() 8 | { 9 | int i; 10 | int known_sum; 11 | int sum = 0; 12 | int result = 0; /* counts the wrong sums from tasks */ 13 | 14 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 15 | 16 | #pragma omp parallel 17 | { 18 | #pragma omp single 19 | { 20 | for (i = 0; i < NUM_TASKS; i++) { 21 | #pragma omp task private(sum) shared(result, known_sum) 22 | { 23 | int j; 24 | //if sum is private, initialize to 0 25 | sum = 0; 26 | for (j = 0; j <= LOOPCOUNT; j++) { 27 | #pragma omp flush 28 | sum += j; 29 | } 30 | /* check if calculated sum was right */ 31 | if (sum != known_sum) { 32 | #pragma omp critical 33 | result++; 34 | } 35 | } /* end of omp task */ 36 | } /* end of for */ 37 | } /* end of single */ 38 | } /* end of parallel*/ 39 | return (result == 0); 40 | } 41 | 42 | int main() 43 | { 44 | int i; 45 | int num_failed=0; 46 | 47 | for(i = 0; i < REPETITIONS; i++) { 48 | if(!test_omp_task_private()) { 49 | num_failed++; 50 | } 51 | } 52 | return num_failed; 53 | } 54 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_task_shared.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | /* Utility function do spend some time in a loop */ 7 | int test_omp_task_imp_shared() 8 | { 9 | int i; 10 | int k = 0; 11 | int result = 0; 12 | i=0; 13 | 14 | #pragma omp parallel 15 | { 16 | #pragma omp single 17 | for (k = 0; k < NUM_TASKS; k++) { 18 | #pragma omp task shared(i) 19 | { 20 | #pragma omp atomic 21 | i++; 22 | //this should be shared implicitly 23 | } 24 | } 25 | } 26 | result = i; 27 | return ((result == NUM_TASKS)); 28 | } 29 | 30 | int main() 31 | { 32 | int i; 33 | int num_failed=0; 34 | 35 | for(i = 0; i < REPETITIONS; i++) { 36 | if(!test_omp_task_imp_shared()) { 37 | num_failed++; 38 | } 39 | } 40 | return num_failed; 41 | } 42 | -------------------------------------------------------------------------------- /runtime/test/tasking/omp_taskloop_taskwait.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | int main() 5 | { 6 | enum {ITERS = 500}; 7 | enum {SIZE = 5}; 8 | int err = 0; 9 | #pragma omp parallel num_threads(2) reduction(+:err) 10 | { 11 | int r = 0; 12 | int i; 13 | #pragma omp taskloop grainsize(SIZE) shared(r) nogroup 14 | for(i=0; i 5 | #include 6 | #include 7 | #include "omp_my_sleep.h" 8 | 9 | int a = 0; 10 | 11 | void task1() { 12 | my_sleep(0.5); 13 | a = 10; 14 | } 15 | 16 | void task2() { 17 | a++; 18 | } 19 | 20 | int main(int argc, char** argv) 21 | { 22 | #pragma omp parallel shared(argc) num_threads(2) 23 | { 24 | #pragma omp single 25 | { 26 | #pragma omp task depend(out: a) 27 | task1(); 28 | 29 | #pragma omp task if(0) depend(inout: a) 30 | task2(); 31 | } 32 | } 33 | if (a != 11) { 34 | fprintf(stderr, "fail: expected 11, but a is %d\n", a); 35 | exit(1); 36 | } else { 37 | printf("pass\n"); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /runtime/test/threadprivate/omp_threadprivate_for.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: !(abt && (clang || gcc)) 3 | #include "omp_testsuite.h" 4 | #include 5 | #include 6 | 7 | static int i; 8 | #pragma omp threadprivate(i) 9 | 10 | int test_omp_threadprivate_for() 11 | { 12 | int known_sum; 13 | int sum; 14 | 15 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 16 | sum = 0; 17 | 18 | #pragma omp parallel 19 | { 20 | int sum0 = 0, i0; 21 | #pragma omp for 22 | for (i0 = 1; i0 <= LOOPCOUNT; i0++) { 23 | i = i0; 24 | sum0 = sum0 + i; 25 | } 26 | #pragma omp critical 27 | { 28 | sum = sum + sum0; 29 | } 30 | } /* end of parallel */ 31 | 32 | if (known_sum != sum ) { 33 | fprintf(stderr, " known_sum = %d, sum = %d\n", known_sum, sum); 34 | } 35 | return (known_sum == sum); 36 | } /* end of check_threadprivate*/ 37 | 38 | int main() 39 | { 40 | int i; 41 | int num_failed=0; 42 | 43 | for(i = 0; i < REPETITIONS; i++) { 44 | if(!test_omp_threadprivate_for()) { 45 | num_failed++; 46 | } 47 | } 48 | return num_failed; 49 | } 50 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/bug_set_schedule_0.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | #include 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | /* Test that the chunk size is set to default (1) when 8 | chunk size <= 0 is specified */ 9 | int a = 0; 10 | 11 | int test_set_schedule_0() 12 | { 13 | int i; 14 | a = 0; 15 | omp_set_schedule(omp_sched_dynamic,0); 16 | 17 | #pragma omp parallel 18 | { 19 | #pragma omp for schedule(runtime) 20 | for(i = 0; i < 10; i++) { 21 | #pragma omp atomic 22 | a++; 23 | if(a > 10) 24 | exit(1); 25 | } 26 | } 27 | return a==10; 28 | } 29 | 30 | int main() 31 | { 32 | int i; 33 | int num_failed=0; 34 | 35 | for(i = 0; i < REPETITIONS; i++) { 36 | if(!test_set_schedule_0()) { 37 | num_failed++; 38 | } 39 | } 40 | return num_failed; 41 | } 42 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_collapse.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: !abt 3 | #include 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | /* Utility function to check that i is increasing monotonically 8 | with each call */ 9 | static int check_i_islarger (int i) 10 | { 11 | static int last_i; 12 | int islarger; 13 | if (i==1) 14 | last_i=0; 15 | islarger = ((i >= last_i)&&(i - last_i<=1)); 16 | last_i = i; 17 | return (islarger); 18 | } 19 | 20 | int test_omp_for_collapse() 21 | { 22 | int is_larger = 1; 23 | 24 | #pragma omp parallel 25 | { 26 | int i,j; 27 | int my_islarger = 1; 28 | #pragma omp for private(i,j) schedule(static,1) collapse(2) ordered 29 | for (i = 1; i < 100; i++) { 30 | for (j =1; j <100; j++) { 31 | #pragma omp ordered 32 | my_islarger = check_i_islarger(i)&&my_islarger; 33 | } 34 | } 35 | #pragma omp critical 36 | is_larger = is_larger && my_islarger; 37 | } 38 | return (is_larger); 39 | } 40 | 41 | int main() 42 | { 43 | int i; 44 | int num_failed=0; 45 | 46 | for(i = 0; i < REPETITIONS; i++) { 47 | if(!test_omp_for_collapse()) { 48 | num_failed++; 49 | } 50 | } 51 | return num_failed; 52 | } 53 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_collapse_mini.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | /* Utility function to check that i is increasing monotonically 7 | with each call */ 8 | static int check_i_islarger (int i) 9 | { 10 | static int last_i; 11 | int islarger; 12 | if (i==1) 13 | last_i=0; 14 | islarger = ((i >= last_i)&&(i - last_i<=1)); 15 | last_i = i; 16 | return (islarger); 17 | } 18 | 19 | int test_omp_for_collapse() 20 | { 21 | int is_larger = 1; 22 | 23 | #pragma omp parallel 24 | { 25 | int i,j; 26 | int my_islarger = 1; 27 | #pragma omp for private(i,j) schedule(static,1) collapse(2) ordered 28 | for (i = 1; i < 5; i++) { 29 | for (j =1; j < 5; j++) { 30 | #pragma omp ordered 31 | my_islarger = check_i_islarger(i)&&my_islarger; 32 | } 33 | } 34 | #pragma omp critical 35 | is_larger = is_larger && my_islarger; 36 | } 37 | return (is_larger); 38 | } 39 | 40 | int main() 41 | { 42 | int i; 43 | int num_failed=0; 44 | 45 | for(i = 0; i < REPETITIONS; i++) { 46 | if(!test_omp_for_collapse()) { 47 | num_failed++; 48 | } 49 | } 50 | return num_failed; 51 | } 52 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: !(abt && (clang || gcc)) 3 | #include 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | int sum1; 8 | #pragma omp threadprivate(sum1) 9 | 10 | int test_omp_for_firstprivate() 11 | { 12 | int sum; 13 | int sum0; 14 | int known_sum; 15 | int threadsnum; 16 | 17 | sum = 0; 18 | sum0 = 12345; 19 | sum1 = 0; 20 | 21 | #pragma omp parallel 22 | { 23 | #pragma omp single 24 | { 25 | threadsnum=omp_get_num_threads(); 26 | } 27 | /* sum0 = 0; */ 28 | 29 | int i; 30 | #pragma omp for firstprivate(sum0) 31 | for (i = 1; i <= LOOPCOUNT; i++) { 32 | sum0 = sum0 + i; 33 | sum1 = sum0; 34 | } /* end of for */ 35 | 36 | #pragma omp critical 37 | { 38 | sum = sum + sum1; 39 | } /* end of critical */ 40 | } /* end of parallel */ 41 | known_sum = 12345* threadsnum+ (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 42 | return (known_sum == sum); 43 | } 44 | 45 | int main() 46 | { 47 | int i; 48 | int num_failed=0; 49 | 50 | for(i = 0; i < REPETITIONS; i++) { 51 | if(!test_omp_for_firstprivate()) { 52 | num_failed++; 53 | } 54 | } 55 | return num_failed; 56 | } 57 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_firstprivate_nothreadprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_omp_for_firstprivate() 7 | { 8 | int sum; 9 | int sum0; 10 | int known_sum; 11 | int threadsnum; 12 | 13 | sum = 0; 14 | sum0 = 12345; 15 | 16 | #pragma omp parallel 17 | { 18 | int sum1 = 0; 19 | #pragma omp single 20 | { 21 | threadsnum=omp_get_num_threads(); 22 | } 23 | /* sum0 = 0; */ 24 | 25 | int i; 26 | #pragma omp for firstprivate(sum0) 27 | for (i = 1; i <= LOOPCOUNT; i++) { 28 | sum0 = sum0 + i; 29 | sum1 = sum0; 30 | } /* end of for */ 31 | 32 | #pragma omp critical 33 | { 34 | sum = sum + sum1; 35 | } /* end of critical */ 36 | } /* end of parallel */ 37 | known_sum = 12345* threadsnum+ (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 38 | return (known_sum == sum); 39 | } 40 | 41 | int main() 42 | { 43 | int i; 44 | int num_failed=0; 45 | 46 | for(i = 0; i < REPETITIONS; i++) { 47 | if(!test_omp_for_firstprivate()) { 48 | num_failed++; 49 | } 50 | } 51 | return num_failed; 52 | } 53 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_lastprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | // REQUIRES: !(abt && (clang || gcc)) 3 | #include 4 | #include 5 | #include "omp_testsuite.h" 6 | 7 | int sum0; 8 | #pragma omp threadprivate(sum0) 9 | 10 | int test_omp_for_lastprivate() 11 | { 12 | int sum = 0; 13 | int known_sum; 14 | int i0; 15 | 16 | i0 = -1; 17 | 18 | #pragma omp parallel 19 | { 20 | sum0 = 0; 21 | { /* Begin of orphaned block */ 22 | int i; 23 | #pragma omp for schedule(static,7) lastprivate(i0) 24 | for (i = 1; i <= LOOPCOUNT; i++) { 25 | sum0 = sum0 + i; 26 | i0 = i; 27 | } /* end of for */ 28 | } /* end of orphaned block */ 29 | 30 | #pragma omp critical 31 | { 32 | sum = sum + sum0; 33 | } /* end of critical */ 34 | } /* end of parallel */ 35 | 36 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 37 | fprintf(stderr, "known_sum = %d , sum = %d\n",known_sum,sum); 38 | fprintf(stderr, "LOOPCOUNT = %d , i0 = %d\n",LOOPCOUNT,i0); 39 | return ((known_sum == sum) && (i0 == LOOPCOUNT)); 40 | } 41 | 42 | int main() 43 | { 44 | int i; 45 | int num_failed=0; 46 | 47 | for (i = 0; i < REPETITIONS; i++) { 48 | if(!test_omp_for_lastprivate()) { 49 | num_failed++; 50 | } 51 | } 52 | return num_failed; 53 | } 54 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_lastprivate_nothreadprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_omp_for_lastprivate() 7 | { 8 | int sum = 0; 9 | int known_sum; 10 | int i0; 11 | 12 | i0 = -1; 13 | 14 | #pragma omp parallel 15 | { 16 | int sum0 = 0; 17 | { /* Begin of orphaned block */ 18 | int i; 19 | #pragma omp for schedule(static,7) lastprivate(i0) 20 | for (i = 1; i <= LOOPCOUNT; i++) { 21 | sum0 = sum0 + i; 22 | i0 = i; 23 | } /* end of for */ 24 | } /* end of orphaned block */ 25 | 26 | #pragma omp critical 27 | { 28 | sum = sum + sum0; 29 | } /* end of critical */ 30 | } /* end of parallel */ 31 | 32 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 33 | fprintf(stderr, "known_sum = %d , sum = %d\n",known_sum,sum); 34 | fprintf(stderr, "LOOPCOUNT = %d , i0 = %d\n",LOOPCOUNT,i0); 35 | return ((known_sum == sum) && (i0 == LOOPCOUNT)); 36 | } 37 | 38 | int main() 39 | { 40 | int i; 41 | int num_failed=0; 42 | 43 | for (i = 0; i < REPETITIONS; i++) { 44 | if(!test_omp_for_lastprivate()) { 45 | num_failed++; 46 | } 47 | } 48 | return num_failed; 49 | } 50 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_for_ordered.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | static int last_i = 0; 7 | 8 | /* Utility function to check that i is increasing monotonically 9 | with each call */ 10 | static int check_i_islarger (int i) 11 | { 12 | int islarger; 13 | islarger = (i > last_i); 14 | last_i = i; 15 | return (islarger); 16 | } 17 | 18 | int test_omp_for_ordered() 19 | { 20 | int sum; 21 | int is_larger = 1; 22 | int known_sum; 23 | 24 | last_i = 0; 25 | sum = 0; 26 | 27 | #pragma omp parallel 28 | { 29 | int i; 30 | int my_islarger = 1; 31 | #pragma omp for schedule(static,1) ordered 32 | for (i = 1; i < 100; i++) { 33 | #pragma omp ordered 34 | { 35 | my_islarger = check_i_islarger(i) && my_islarger; 36 | sum = sum + i; 37 | } 38 | } 39 | #pragma omp critical 40 | { 41 | is_larger = is_larger && my_islarger; 42 | } 43 | } 44 | 45 | known_sum=(99 * 100) / 2; 46 | return ((known_sum == sum) && is_larger); 47 | } 48 | 49 | int main() 50 | { 51 | int i; 52 | int num_failed=0; 53 | 54 | for(i = 0; i < REPETITIONS; i++) { 55 | if(!test_omp_for_ordered()) { 56 | num_failed++; 57 | } 58 | } 59 | return num_failed; 60 | } 61 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_nonmonotonic_dynamic1.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile 2 | // RUN: env OMP_SCHEDULE=nonmonotonic:dynamic,10 %libomp-run 3 | 4 | // The test checks iterations distribution for OMP 5.0 nonmonotonic OMP_SCHEDULE 5 | // case #threads > #chunks (fallback to monotonic dynamic) 6 | 7 | #include 8 | #include 9 | 10 | #define ITERS 100 11 | #define CHUNK 10 12 | int err = 0; 13 | 14 | int main(int argc, char **argv) { 15 | int i, ch, it[ITERS]; 16 | omp_set_num_threads(16); // #threads is bigger than #chunks 17 | #pragma omp parallel for schedule(runtime) 18 | for (i = 0; i < ITERS; ++i) { 19 | it[i] = omp_get_thread_num(); 20 | } 21 | // check that each chunk executed by single thread 22 | for (ch = 0; ch < ITERS/CHUNK; ++ch) { 23 | int iter = ch * CHUNK; 24 | int nt = it[iter]; // thread number 25 | for (i = 1; i < CHUNK; ++i) { 26 | #if _DEBUG 27 | printf("iter %d: (%d %d)\n", iter + i, nt, it[iter + i]); 28 | #endif 29 | if (nt != it[iter + i]) { 30 | err++; 31 | } 32 | } 33 | } 34 | if (err > 0) { 35 | printf("Failed, err = %d\n", err); 36 | return 1; 37 | } 38 | printf("Passed\n"); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_nonmonotonic_nowait.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | 3 | // The test checks nonmonotonic scheduling works correctly when threads 4 | // may execute different loops concurrently. 5 | 6 | #include 7 | #include 8 | 9 | #define N 200 10 | #define C 20 11 | int main() 12 | { 13 | int i, l0 = 0, l1 = 0; 14 | #pragma omp parallel num_threads(8) 15 | { 16 | #pragma omp for schedule(nonmonotonic:dynamic,C) nowait 17 | for (i = 0; i < N; ++i) { 18 | #pragma omp atomic 19 | l0++; 20 | } 21 | #pragma omp for schedule(nonmonotonic:dynamic,C) nowait 22 | for (i = 0; i < N * N; ++i) { 23 | #pragma omp atomic 24 | l1++; 25 | } 26 | } 27 | if (l0 != N || l1 != N * N) { 28 | printf("failed l0 = %d, l1 = %d, should be %d %d\n", l0, l1, N, N * N); 29 | return 1; 30 | } else { 31 | printf("passed\n"); 32 | return 0; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_parallel_for_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_for_firstprivate() 6 | { 7 | int sum ; 8 | int i2; 9 | int i; 10 | int known_sum; 11 | 12 | sum=0; 13 | i2=3; 14 | 15 | #pragma omp parallel for reduction(+:sum) private(i) firstprivate(i2) 16 | for (i = 1; i <= LOOPCOUNT; i++) { 17 | sum = sum + (i + i2); 18 | } 19 | 20 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 + i2 * LOOPCOUNT; 21 | return (known_sum == sum); 22 | } /* end of check_parallel_for_fistprivate */ 23 | 24 | int main() 25 | { 26 | int i; 27 | int num_failed=0; 28 | 29 | for(i = 0; i < REPETITIONS; i++) { 30 | if(!test_omp_parallel_for_firstprivate()) { 31 | num_failed++; 32 | } 33 | } 34 | return num_failed; 35 | } 36 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_parallel_for_if.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | int test_omp_parallel_for_if() 7 | { 8 | int known_sum; 9 | int num_threads; 10 | int sum, sum2; 11 | int i; 12 | int control; 13 | 14 | control = 0; 15 | num_threads=0; 16 | sum = 0; 17 | sum2 = 0; 18 | 19 | #pragma omp parallel for private(i) if (control==1) 20 | for (i=0; i <= LOOPCOUNT; i++) { 21 | num_threads = omp_get_num_threads(); 22 | sum = sum + i; 23 | } 24 | 25 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 26 | fprintf(stderr, "Number of threads determined by" 27 | " omp_get_num_threads: %d\n", num_threads); 28 | return (known_sum == sum && num_threads == 1); 29 | } /* end of check_parallel_for_private */ 30 | 31 | int main() 32 | { 33 | int i; 34 | int num_failed=0; 35 | 36 | for(i = 0; i < REPETITIONS; i++) { 37 | if(!test_omp_parallel_for_if()) { 38 | num_failed++; 39 | } 40 | } 41 | return num_failed; 42 | } 43 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_parallel_for_lastprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_for_lastprivate() 6 | { 7 | int sum; 8 | int i; 9 | int i0; 10 | int known_sum; 11 | 12 | sum =0; 13 | i0 = -1; 14 | 15 | #pragma omp parallel for reduction(+:sum) \ 16 | schedule(static,7) private(i) lastprivate(i0) 17 | for (i = 1; i <= LOOPCOUNT; i++) { 18 | sum = sum + i; 19 | i0 = i; 20 | } /* end of parallel for */ 21 | 22 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 23 | return ((known_sum == sum) && (i0 == LOOPCOUNT)); 24 | } /* end of check_parallel_for_lastprivate */ 25 | 26 | int main() 27 | { 28 | int i; 29 | int num_failed=0; 30 | 31 | for(i = 0; i < REPETITIONS; i++) { 32 | if(!test_omp_parallel_for_lastprivate()) { 33 | num_failed++; 34 | } 35 | } 36 | return num_failed; 37 | } 38 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_parallel_for_ordered_nothreadprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | static int last_i = 0; 6 | 7 | /*! 8 | Utility function: returns true if the passed argument is larger than 9 | the argument of the last call of this function. 10 | */ 11 | static int check_i_islarger2(int i) 12 | { 13 | int islarger; 14 | islarger = (i > last_i); 15 | last_i = i; 16 | return (islarger); 17 | } 18 | 19 | int test_omp_parallel_for_ordered() 20 | { 21 | int sum; 22 | int is_larger; 23 | int known_sum; 24 | int i; 25 | 26 | sum = 0; 27 | is_larger = 1; 28 | last_i = 0; 29 | #pragma omp parallel for schedule(static,1) private(i) ordered 30 | for (i = 1; i < 100; i++) { 31 | int ii = i; 32 | #pragma omp ordered 33 | { 34 | is_larger = check_i_islarger2 (ii) && is_larger; 35 | sum = sum + ii; 36 | } 37 | } 38 | known_sum = (99 * 100) / 2; 39 | fprintf (stderr," known_sum = %d , sum = %d \n", known_sum, sum); 40 | fprintf (stderr," is_larger = %d\n", is_larger); 41 | return (known_sum == sum) && is_larger; 42 | } 43 | 44 | int main() 45 | { 46 | int i; 47 | int num_failed=0; 48 | 49 | for(i = 0; i < REPETITIONS; i++) { 50 | if(!test_omp_parallel_for_ordered()) { 51 | num_failed++; 52 | } 53 | } 54 | return num_failed; 55 | } 56 | -------------------------------------------------------------------------------- /runtime/test/worksharing/for/omp_parallel_for_private.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include 4 | #include "omp_testsuite.h" 5 | 6 | /*! Utility function to spend some time in a loop */ 7 | static void do_some_work (void) 8 | { 9 | int i; 10 | double sum = 0; 11 | for(i = 0; i < 1000; i++){ 12 | sum += sqrt (i); 13 | } 14 | } 15 | 16 | int test_omp_parallel_for_private() 17 | { 18 | int sum; 19 | int i; 20 | int i2; 21 | int known_sum; 22 | 23 | sum =0; 24 | i2=0; 25 | 26 | #pragma omp parallel for reduction(+:sum) schedule(static,1) private(i) private(i2) 27 | for (i=1;i<=LOOPCOUNT;i++) 28 | { 29 | i2 = i; 30 | #pragma omp flush 31 | do_some_work (); 32 | #pragma omp flush 33 | sum = sum + i2; 34 | } /*end of for*/ 35 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; 36 | return (known_sum == sum); 37 | } /* end of check_parallel_for_private */ 38 | 39 | int main() 40 | { 41 | int i; 42 | int num_failed=0; 43 | 44 | for(i = 0; i < REPETITIONS; i++) { 45 | if(!test_omp_parallel_for_private()) { 46 | num_failed++; 47 | } 48 | } 49 | return num_failed; 50 | } 51 | -------------------------------------------------------------------------------- /runtime/test/worksharing/sections/omp_parallel_sections_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_sections_firstprivate() 6 | { 7 | int sum; 8 | int sum0; 9 | int known_sum; 10 | 11 | sum =7; 12 | sum0=11; 13 | 14 | #pragma omp parallel sections firstprivate(sum0) 15 | { 16 | #pragma omp section 17 | { 18 | #pragma omp critical 19 | { 20 | sum= sum+sum0; 21 | } 22 | } 23 | #pragma omp section 24 | { 25 | #pragma omp critical 26 | { 27 | sum= sum+sum0; 28 | } 29 | } 30 | #pragma omp section 31 | { 32 | #pragma omp critical 33 | { 34 | sum= sum+sum0; 35 | } 36 | } 37 | } 38 | 39 | known_sum=11*3+7; 40 | return (known_sum==sum); 41 | } /* end of check_section_firstprivate*/ 42 | 43 | int main() 44 | { 45 | int i; 46 | int num_failed=0; 47 | 48 | for(i = 0; i < REPETITIONS; i++) { 49 | if(!test_omp_parallel_sections_firstprivate()) { 50 | num_failed++; 51 | } 52 | } 53 | return num_failed; 54 | } 55 | -------------------------------------------------------------------------------- /runtime/test/worksharing/sections/omp_parallel_sections_private.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_parallel_sections_private() 6 | { 7 | int sum; 8 | int sum0; 9 | int i; 10 | int known_sum; 11 | 12 | sum = 7; 13 | sum0=0; 14 | 15 | #pragma omp parallel sections private(sum0, i) 16 | { 17 | #pragma omp section 18 | { 19 | sum0=0; 20 | for (i=1;i<400;i++) 21 | sum0=sum0+i; 22 | #pragma omp critical 23 | { 24 | sum= sum+sum0; 25 | } 26 | } 27 | #pragma omp section 28 | { 29 | sum0=0; 30 | for(i=400;i<700;i++) 31 | sum0=sum0+i; 32 | #pragma omp critical 33 | { 34 | sum= sum+sum0; 35 | } 36 | } 37 | #pragma omp section 38 | { 39 | sum0=0; 40 | for(i=700;i<1000;i++) 41 | sum0=sum0+i; 42 | #pragma omp critical 43 | { 44 | sum= sum+sum0; 45 | } 46 | } 47 | } 48 | 49 | known_sum=(999*1000)/2+7; 50 | return (known_sum==sum); 51 | } /* end of check_section_private*/ 52 | 53 | int main() 54 | { 55 | int i; 56 | int num_failed=0; 57 | 58 | for(i = 0; i < REPETITIONS; i++) { 59 | if(!test_omp_parallel_sections_private()) { 60 | num_failed++; 61 | } 62 | } 63 | return num_failed; 64 | } 65 | -------------------------------------------------------------------------------- /runtime/test/worksharing/sections/omp_section_firstprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_section_firstprivate() 6 | { 7 | int sum; 8 | int sum0; 9 | int known_sum; 10 | 11 | sum0 = 11; 12 | sum = 7; 13 | #pragma omp parallel 14 | { 15 | #pragma omp sections firstprivate(sum0) 16 | { 17 | #pragma omp section 18 | { 19 | #pragma omp critical 20 | { 21 | sum = sum + sum0; 22 | } 23 | } 24 | #pragma omp section 25 | { 26 | #pragma omp critical 27 | { 28 | sum = sum + sum0; 29 | } 30 | } 31 | #pragma omp section 32 | { 33 | #pragma omp critical 34 | { 35 | sum = sum + sum0; 36 | } 37 | } 38 | } 39 | } 40 | known_sum = 11 * 3 + 7; 41 | return (known_sum == sum); 42 | } /* end of check_section_firstprivate*/ 43 | 44 | int main() 45 | { 46 | int i; 47 | int num_failed=0; 48 | 49 | for(i = 0; i < REPETITIONS; i++) { 50 | if(!test_omp_section_firstprivate()) { 51 | num_failed++; 52 | } 53 | } 54 | return num_failed; 55 | } 56 | -------------------------------------------------------------------------------- /runtime/test/worksharing/single/omp_single.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_single() 6 | { 7 | int nr_threads_in_single; 8 | int result; 9 | int nr_iterations; 10 | int i; 11 | 12 | nr_threads_in_single = 0; 13 | result = 0; 14 | nr_iterations = 0; 15 | 16 | #pragma omp parallel private(i) 17 | { 18 | for (i = 0; i < LOOPCOUNT; i++) { 19 | #pragma omp single 20 | { 21 | #pragma omp flush 22 | nr_threads_in_single++; 23 | #pragma omp flush 24 | nr_iterations++; 25 | nr_threads_in_single--; 26 | result = result + nr_threads_in_single; 27 | } 28 | } 29 | } 30 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 31 | } /* end of check_single*/ 32 | 33 | int main() 34 | { 35 | int i; 36 | int num_failed=0; 37 | 38 | for(i = 0; i < REPETITIONS; i++) { 39 | if(!test_omp_single()) { 40 | num_failed++; 41 | } 42 | } 43 | return num_failed; 44 | } 45 | -------------------------------------------------------------------------------- /runtime/test/worksharing/single/omp_single_copyprivate_nothreadprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include "omp_testsuite.h" 3 | 4 | #define DEBUG_TEST 0 5 | 6 | int test_omp_single_copyprivate() 7 | { 8 | int result; 9 | int nr_iterations; 10 | 11 | result = 0; 12 | nr_iterations = 0; 13 | int j; 14 | #pragma omp parallel num_threads(4) private(j) 15 | { 16 | int i; 17 | for (i = 0; i < LOOPCOUNT; i++) 18 | { 19 | #if DEBUG_TEST 20 | int thread; 21 | thread = omp_get_thread_num (); 22 | #endif 23 | #pragma omp single copyprivate(j) 24 | { 25 | nr_iterations++; 26 | j = i; 27 | #if DEBUG_TEST 28 | printf ("thread %d assigns, j = %d, i = %d\n", thread, j, i); 29 | #endif 30 | } 31 | #if DEBUG_TEST 32 | #pragma omp barrier 33 | #endif 34 | #pragma omp critical 35 | { 36 | #if DEBUG_TEST 37 | printf ("thread = %d, j = %d, i = %d\n", thread, j, i); 38 | #endif 39 | result = result + j - i; 40 | } 41 | #pragma omp barrier 42 | } /* end of for */ 43 | } /* end of parallel */ 44 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 45 | } 46 | 47 | int main() 48 | { 49 | int i; 50 | int num_failed=0; 51 | 52 | for(i = 0; i < REPETITIONS; i++) { 53 | if(!test_omp_single_copyprivate()) { 54 | num_failed++; 55 | } 56 | } 57 | return num_failed; 58 | } 59 | -------------------------------------------------------------------------------- /runtime/test/worksharing/single/omp_single_private_nothreadprivate.c: -------------------------------------------------------------------------------- 1 | // RUN: %libomp-compile-and-run 2 | #include 3 | #include "omp_testsuite.h" 4 | 5 | int test_omp_single_private() 6 | { 7 | int nr_threads_in_single; 8 | int result; 9 | int nr_iterations; 10 | int i; 11 | 12 | nr_threads_in_single = 0; 13 | nr_iterations = 0; 14 | result = 0; 15 | 16 | #pragma omp parallel private(i) 17 | { 18 | int myresult = 0; 19 | int myit = 0; 20 | for (i = 0; i < LOOPCOUNT; i++) { 21 | #pragma omp single private(nr_threads_in_single) nowait 22 | { 23 | nr_threads_in_single = 0; 24 | #pragma omp flush 25 | nr_threads_in_single++; 26 | #pragma omp flush 27 | myit++; 28 | myresult = myresult + nr_threads_in_single; 29 | } 30 | } 31 | #pragma omp critical 32 | { 33 | result += nr_threads_in_single; 34 | nr_iterations += myit; 35 | } 36 | } 37 | return ((result == 0) && (nr_iterations == LOOPCOUNT)); 38 | } /* end of check_single private */ 39 | 40 | int main() 41 | { 42 | int i; 43 | int num_failed=0; 44 | 45 | for(i = 0; i < REPETITIONS; i++) { 46 | if(!test_omp_single_private()) { 47 | num_failed++; 48 | } 49 | } 50 | return num_failed; 51 | } 52 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Discover the tools that use CMake in the subdirectories. 2 | # Note that explicit cmake invocation is required every time a new tool 3 | # is added or removed. 4 | file(GLOB entries *) 5 | foreach(entry ${entries}) 6 | if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt) 7 | add_subdirectory(${entry}) 8 | endif() 9 | endforeach(entry) 10 | -------------------------------------------------------------------------------- /tools/analyzer/llvm-openmp-analyzer++: -------------------------------------------------------------------------------- 1 | llvm-openmp-analyzer -------------------------------------------------------------------------------- /tools/archer/tests/barrier/barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | // RUN: %libarcher-compile-and-run | FileCheck %s 15 | // REQUIRES: tsan 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | int var = 0; 21 | 22 | #pragma omp parallel num_threads(2) shared(var) 23 | { 24 | if (omp_get_thread_num() == 0) { 25 | var++; 26 | } 27 | 28 | #pragma omp barrier 29 | 30 | if (omp_get_thread_num() == 1) { 31 | var++; 32 | } 33 | } 34 | 35 | fprintf(stderr, "DONE\n"); 36 | int error = (var != 2); 37 | return error; 38 | } 39 | 40 | // CHECK-NOT: ThreadSanitizer: data race 41 | // CHECK-NOT: ThreadSanitizer: reported 42 | // CHECK: DONE 43 | -------------------------------------------------------------------------------- /tools/archer/tests/critical/critical.c: -------------------------------------------------------------------------------- 1 | /* 2 | * critical.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | #pragma omp parallel num_threads(8) shared(var) 24 | { 25 | #pragma omp critical 26 | { var++; } 27 | } 28 | 29 | fprintf(stderr, "DONE\n"); 30 | int error = (var != 8); 31 | return error; 32 | } 33 | 34 | // CHECK-NOT: ThreadSanitizer: data race 35 | // CHECK-NOT: ThreadSanitizer: reported 36 | // CHECK: DONE 37 | -------------------------------------------------------------------------------- /tools/archer/tests/critical/lock-nested.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lock-nested.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | omp_nest_lock_t lock; 24 | omp_init_nest_lock(&lock); 25 | 26 | #pragma omp parallel num_threads(2) shared(var) 27 | { 28 | omp_set_nest_lock(&lock); 29 | omp_set_nest_lock(&lock); 30 | var++; 31 | omp_unset_nest_lock(&lock); 32 | omp_unset_nest_lock(&lock); 33 | } 34 | 35 | omp_destroy_nest_lock(&lock); 36 | 37 | fprintf(stderr, "DONE\n"); 38 | int error = (var != 2); 39 | return error; 40 | } 41 | 42 | // CHECK-NOT: ThreadSanitizer: data race 43 | // CHECK-NOT: ThreadSanitizer: reported 44 | // CHECK: DONE 45 | -------------------------------------------------------------------------------- /tools/archer/tests/critical/lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lock.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | omp_lock_t lock; 24 | omp_init_lock(&lock); 25 | 26 | #pragma omp parallel num_threads(2) shared(var) 27 | { 28 | omp_set_lock(&lock); 29 | var++; 30 | omp_unset_lock(&lock); 31 | } 32 | 33 | omp_destroy_lock(&lock); 34 | 35 | fprintf(stderr, "DONE\n"); 36 | int error = (var != 2); 37 | return error; 38 | } 39 | 40 | // CHECK-NOT: ThreadSanitizer: data race 41 | // CHECK-NOT: ThreadSanitizer: reported 42 | // CHECK: DONE 43 | -------------------------------------------------------------------------------- /tools/archer/tests/deflake.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script is used to deflake inherently flaky archer tests. 3 | # It is invoked from lit tests as: 4 | # %deflake mybinary 5 | # which is then substituted by lit to: 6 | # $(dirname %s)/deflake.bash mybinary 7 | # The script runs the target program up to 10 times, 8 | # until it fails (i.e. produces a race report). 9 | 10 | for i in $(seq 1 10); do 11 | OUT=`$@ 2>&1` 12 | if [[ $? != 0 ]]; then 13 | echo "$OUT" 14 | exit 0 15 | fi 16 | done 17 | exit 1 18 | -------------------------------------------------------------------------------- /tools/archer/tests/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @AUTO_GEN_COMMENT@ 2 | 3 | config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" 4 | config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" 5 | config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ 6 | config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" 7 | config.test_not = "@OPENMP_NOT_EXECUTABLE@" 8 | config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" 9 | config.test_extra_flags = "@OPENMP_TEST_FLAGS@" 10 | config.libomp_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" 11 | config.omp_library_dir = "@LIBBOLT_LIBRARY_DIR@" 12 | config.omp_header_dir = "@LIBBOLT_INCLUDE_DIR@" 13 | config.operating_system = "@CMAKE_SYSTEM_NAME@" 14 | config.has_libatomic = @LIBARCHER_HAVE_LIBATOMIC@ 15 | config.has_tsan = @OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS@ 16 | 17 | config.test_archer_flags = "@LIBARCHER_TEST_FLAGS@" 18 | config.libarcher_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" 19 | 20 | # Let the main config do the real work. 21 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") 22 | -------------------------------------------------------------------------------- /tools/archer/tests/ompt/ompt-signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ompt-signal.h -- Header providing low-level synchronization for tests 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // The LLVM Compiler Infrastructure 8 | // 9 | // This file is a copy from runtime/test/ompt/ 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #if defined(WIN32) || defined(_WIN32) 14 | #include 15 | #define delay() Sleep(1); 16 | #else 17 | #include 18 | #define delay(t) usleep(t); 19 | #endif 20 | 21 | // These functions are used to provide a signal-wait mechanism to enforce 22 | // expected scheduling for the test cases. 23 | // Conditional variable (s) needs to be shared! Initialize to 0 24 | 25 | #define OMPT_SIGNAL(s) ompt_signal(&s) 26 | // inline 27 | void ompt_signal(int *s) { 28 | #pragma omp atomic 29 | (*s)++; 30 | } 31 | 32 | #define OMPT_WAIT(s, v) ompt_wait(&s, v) 33 | // wait for s >= v 34 | // inline 35 | void ompt_wait(int *s, int v) { 36 | int wait = 0; 37 | do { 38 | delay(10); 39 | #pragma omp atomic read 40 | wait = (*s); 41 | } while (wait < v); 42 | } 43 | -------------------------------------------------------------------------------- /tools/archer/tests/parallel/parallel-firstprivate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel-firstprivate.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | #pragma omp parallel num_threads(2) firstprivate(var) 24 | { var = 1; } 25 | 26 | fprintf(stderr, "DONE\n"); 27 | // var should still be 0! 28 | return var; 29 | } 30 | 31 | // CHECK-NOT: ThreadSanitizer: data race 32 | // CHECK-NOT: ThreadSanitizer: reported 33 | // CHECK: DONE 34 | -------------------------------------------------------------------------------- /tools/archer/tests/parallel/parallel-nosuppression.c: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel-nosuppression.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run-nosuppression | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | #pragma omp parallel num_threads(2) shared(var) 24 | { 25 | if (omp_get_thread_num() == 1) { 26 | var++; 27 | } 28 | } // implicit barrier 29 | 30 | var++; 31 | 32 | fprintf(stderr, "DONE\n"); 33 | int error = (var != 2); 34 | return error; 35 | } 36 | 37 | // CHECK: Warning: please export TSAN_OPTIONS 38 | // CHECK: DONE 39 | -------------------------------------------------------------------------------- /tools/archer/tests/parallel/parallel-simple2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel-simple2.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | // Create team of threads so that there is no implicit happens before 24 | // when creating the thread. 25 | #pragma omp parallel num_threads(2) 26 | {} 27 | 28 | var++; 29 | 30 | #pragma omp parallel num_threads(2) shared(var) 31 | { 32 | if (omp_get_thread_num() == 1) { 33 | var++; 34 | } 35 | } // implicit barrier 36 | 37 | fprintf(stderr, "DONE\n"); 38 | int error = (var != 2); 39 | return error; 40 | } 41 | 42 | // CHECK-NOT: ThreadSanitizer: data race 43 | // CHECK-NOT: ThreadSanitizer: reported 44 | // CHECK: DONE 45 | -------------------------------------------------------------------------------- /tools/archer/tests/races/critical-unrelated.c: -------------------------------------------------------------------------------- 1 | /* 2 | * critical-unrelated.c -- Archer testcase 3 | */ 4 | //===----------------------------------------------------------------------===// 5 | // 6 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 7 | // 8 | // See tools/archer/LICENSE.txt for details. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | // RUN: %libarcher-compile-and-run-race | FileCheck %s 14 | // RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s 15 | // REQUIRES: tsan 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | int var = 0; 21 | 22 | #pragma omp parallel num_threads(2) shared(var) 23 | { 24 | #pragma omp critical 25 | { 26 | // Dummy region. 27 | } 28 | 29 | var++; 30 | } 31 | 32 | fprintf(stderr, "DONE\n"); 33 | } 34 | 35 | // CHECK: WARNING: ThreadSanitizer: data race 36 | // CHECK-NEXT: {{(Write|Read)}} of size 4 37 | // CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29 38 | // CHECK: Previous write of size 4 39 | // CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29 40 | // CHECK: DONE 41 | // CHECK: ThreadSanitizer: reported 1 warnings 42 | -------------------------------------------------------------------------------- /tools/archer/tests/races/lock-unrelated.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lock-unrelated.c -- Archer testcase 3 | */ 4 | //===----------------------------------------------------------------------===// 5 | // 6 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 7 | // 8 | // See tools/archer/LICENSE.txt for details. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | // RUN: %libarcher-compile-and-run-race | FileCheck %s 14 | // RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s 15 | // REQUIRES: tsan 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | int var = 0; 21 | 22 | omp_lock_t lock; 23 | omp_init_lock(&lock); 24 | 25 | #pragma omp parallel num_threads(2) shared(var) 26 | { 27 | omp_set_lock(&lock); 28 | // Dummy locking. 29 | omp_unset_lock(&lock); 30 | 31 | var++; 32 | } 33 | 34 | omp_destroy_lock(&lock); 35 | 36 | int error = (var != 2); 37 | fprintf(stderr, "DONE\n"); 38 | return error; 39 | } 40 | 41 | // CHECK: WARNING: ThreadSanitizer: data race 42 | // CHECK-NEXT: {{(Write|Read)}} of size 4 43 | // CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31 44 | // CHECK: Previous write of size 4 45 | // CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31 46 | // CHECK: DONE 47 | // CHECK: ThreadSanitizer: reported 1 warnings 48 | -------------------------------------------------------------------------------- /tools/archer/tests/races/parallel-simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel-simple.c -- Archer testcase 3 | */ 4 | //===----------------------------------------------------------------------===// 5 | // 6 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 7 | // 8 | // See tools/archer/LICENSE.txt for details. 9 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | // RUN: %libarcher-compile-and-run-race | FileCheck %s 14 | // RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s 15 | // REQUIRES: tsan 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | int var = 0; 21 | 22 | #pragma omp parallel num_threads(2) shared(var) 23 | { var++; } 24 | 25 | int error = (var != 2); 26 | fprintf(stderr, "DONE\n"); 27 | return error; 28 | } 29 | 30 | // CHECK: WARNING: ThreadSanitizer: data race 31 | // CHECK-NEXT: {{(Write|Read)}} of size 4 32 | // CHECK-NEXT: #0 {{.*}}parallel-simple.c:23 33 | // CHECK: Previous write of size 4 34 | // CHECK-NEXT: #0 {{.*}}parallel-simple.c:23 35 | // CHECK: DONE 36 | // CHECK: ThreadSanitizer: reported 1 warnings 37 | -------------------------------------------------------------------------------- /tools/archer/tests/reduction/parallel-reduction.c: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel-reduction.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run| FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | int var = 0; 22 | 23 | // Number of threads is empirical: We need enough threads so that 24 | // the reduction is really performed hierarchically in the barrier! 25 | #pragma omp parallel num_threads(5) reduction(+ : var) 26 | { var = 1; } 27 | 28 | fprintf(stderr, "DONE\n"); 29 | int error = (var != 5); 30 | return error; 31 | } 32 | 33 | // CHECK-NOT: ThreadSanitizer: data race 34 | // CHECK-NOT: ThreadSanitizer: reported 35 | // CHECK: DONE 36 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-barrier.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | { 27 | #pragma omp master 28 | { 29 | #pragma omp task shared(var) 30 | { 31 | OMPT_SIGNAL(a); 32 | var++; 33 | } 34 | 35 | // Give other thread time to steal the task. 36 | OMPT_WAIT(a, 1); 37 | } 38 | 39 | #pragma omp barrier 40 | 41 | #pragma omp master 42 | { var++; } 43 | } 44 | 45 | fprintf(stderr, "DONE\n"); 46 | int error = (var != 2); 47 | return error; 48 | } 49 | 50 | // CHECK-NOT: ThreadSanitizer: data race 51 | // CHECK-NOT: ThreadSanitizer: reported 52 | // CHECK: DONE 53 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-create.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-create.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | #pragma omp master 27 | { 28 | var++; 29 | #pragma omp task shared(var, a) 30 | { 31 | var++; 32 | OMPT_SIGNAL(a); 33 | } 34 | 35 | // Give other thread time to steal the task. 36 | OMPT_WAIT(a, 1); 37 | } 38 | 39 | fprintf(stderr, "DONE\n"); 40 | int error = (var != 2); 41 | return error; 42 | } 43 | 44 | // CHECK-NOT: ThreadSanitizer: data race 45 | // CHECK-NOT: ThreadSanitizer: reported 46 | // CHECK: DONE 47 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-taskgroup-nested.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-taskgroup-nested.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | #pragma omp master 27 | { 28 | #pragma omp taskgroup 29 | { 30 | #pragma omp task 31 | { 32 | #pragma omp task shared(var, a) 33 | { 34 | var++; 35 | OMPT_SIGNAL(a); 36 | } 37 | } 38 | 39 | // Give other thread time to steal the task and execute its child. 40 | OMPT_WAIT(a, 1); 41 | } 42 | 43 | var++; 44 | } 45 | 46 | fprintf(stderr, "DONE\n"); 47 | int error = (var != 2); 48 | return error; 49 | } 50 | 51 | // CHECK-NOT: ThreadSanitizer: data race 52 | // CHECK-NOT: ThreadSanitizer: reported 53 | // CHECK: DONE 54 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-taskgroup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-taskgroup.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | #pragma omp master 27 | { 28 | #pragma omp taskgroup 29 | { 30 | #pragma omp task shared(var, a) 31 | { 32 | var++; 33 | OMPT_SIGNAL(a); 34 | } 35 | 36 | // Give other thread time to steal the task. 37 | OMPT_WAIT(a, 1); 38 | } 39 | 40 | var++; 41 | } 42 | 43 | fprintf(stderr, "DONE\n"); 44 | int error = (var != 2); 45 | return error; 46 | } 47 | 48 | // CHECK-NOT: ThreadSanitizer: data race 49 | // CHECK-NOT: ThreadSanitizer: reported 50 | // CHECK: DONE 51 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-taskwait-nested.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-taskwait-nested.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | #pragma omp master 27 | { 28 | #pragma omp task 29 | { 30 | #pragma omp task shared(var, a) 31 | { 32 | OMPT_SIGNAL(a); 33 | delay(100); 34 | var++; 35 | } 36 | #pragma omp taskwait 37 | } 38 | 39 | // Give other thread time to steal the task and execute its child. 40 | OMPT_WAIT(a, 1); 41 | 42 | #pragma omp taskwait 43 | var++; 44 | } 45 | 46 | fprintf(stderr, "DONE\n"); 47 | int error = (var != 2); 48 | return error; 49 | } 50 | 51 | // CHECK-NOT: ThreadSanitizer: data race 52 | // CHECK-NOT: ThreadSanitizer: reported 53 | // CHECK: DONE 54 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task-taskwait.c: -------------------------------------------------------------------------------- 1 | /* 2 | * task-taskwait.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | #include 20 | #include "ompt/ompt-signal.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0, a = 0; 24 | 25 | #pragma omp parallel num_threads(2) shared(var, a) 26 | #pragma omp master 27 | { 28 | #pragma omp task shared(var, a) 29 | { 30 | OMPT_SIGNAL(a); 31 | OMPT_WAIT(a, 2); 32 | delay(100); 33 | var++; 34 | } 35 | 36 | // Give other thread time to steal the task. 37 | OMPT_WAIT(a, 1); 38 | OMPT_SIGNAL(a); 39 | #pragma omp taskwait 40 | var++; 41 | } 42 | 43 | fprintf(stderr, "DONE\n"); 44 | int error = (var != 2); 45 | return error; 46 | } 47 | 48 | // CHECK-NOT: ThreadSanitizer: data race 49 | // CHECK-NOT: ThreadSanitizer: reported 50 | // CHECK: DONE 51 | -------------------------------------------------------------------------------- /tools/archer/tests/task/task_early_fulfill.c: -------------------------------------------------------------------------------- 1 | // RUN: %libarcher-compile -fopenmp-version=50 && env OMP_NUM_THREADS='3' \ 2 | // RUN: %libarcher-run 3 | //| FileCheck %s 4 | 5 | // Checked gcc 9.2 still does not support detach clause on task construct. 6 | // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9 7 | // clang supports detach clause since version 11. 8 | // UNSUPPORTED: clang-10, clang-9, clang-8, clang-7 9 | // icc compiler does not support detach clause. 10 | // UNSUPPORTED: icc 11 | // REQUIRES: tsan 12 | 13 | #include 14 | #include 15 | 16 | int main() { 17 | #pragma omp parallel 18 | #pragma omp master 19 | { 20 | omp_event_handle_t event; 21 | #pragma omp task detach(event) if (0) 22 | { omp_fulfill_event(event); } 23 | #pragma omp taskwait 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tools/archer/tests/worksharing/ordered.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ordered.c -- Archer testcase 3 | */ 4 | 5 | //===----------------------------------------------------------------------===// 6 | // 7 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 8 | // 9 | // See tools/archer/LICENSE.txt for details. 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | 15 | // RUN: %libarcher-compile-and-run | FileCheck %s 16 | // REQUIRES: tsan 17 | #include 18 | #include 19 | 20 | #define NUM_THREADS 2 21 | 22 | int main(int argc, char *argv[]) { 23 | int var = 0; 24 | int i; 25 | 26 | #pragma omp parallel for ordered num_threads(NUM_THREADS) shared(var) 27 | for (i = 0; i < NUM_THREADS; i++) { 28 | #pragma omp ordered 29 | { var++; } 30 | } 31 | 32 | fprintf(stderr, "DONE\n"); 33 | int error = (var != 2); 34 | return error; 35 | } 36 | 37 | // CHECK-NOT: ThreadSanitizer: data race 38 | // CHECK-NOT: ThreadSanitizer: reported 39 | // CHECK: DONE 40 | -------------------------------------------------------------------------------- /tools/multiplex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(LIBOMP_OMPT_SUPPORT) 2 | include_directories(${LIBOMP_INCLUDE_DIR}) 3 | 4 | add_library(bolt-ompt-multiplex INTERFACE) 5 | target_include_directories(bolt-ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 6 | 7 | install(FILES ompt-multiplex.h DESTINATION include) 8 | 9 | add_subdirectory(tests) 10 | endif() 11 | -------------------------------------------------------------------------------- /tools/multiplex/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeLists.txt file for unit testing OMPT multiplex header. 2 | include(CheckFunctionExists) 3 | include(CheckLibraryExists) 4 | 5 | macro(pythonize_bool var) 6 | if (${var}) 7 | set(${var} True) 8 | else() 9 | set(${var} False) 10 | endif() 11 | endmacro() 12 | 13 | set(OMPT_LOAD_CLIENT_TEST_CFLAGS "" CACHE STRING 14 | "Extra compiler flags to send to the test compiler") 15 | 16 | get_target_property(OMPT_PRINT_CALLBACKS_DIR bolt-ompt-print-callback INTERFACE_INCLUDE_DIRECTORIES) 17 | add_openmp_testsuite(check-bolt-ompt-multiplex "Running OMPT multiplex tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS bolt-omp) 18 | 19 | # Configure the lit.site.cfg.in file 20 | set(AUTO_GEN_COMMENT "## Autogenerated by OMPT_LOAD_CLIENT configuration.\n# Do not edit!") 21 | configure_file(lit.site.cfg.in lit.site.cfg @ONLY) 22 | -------------------------------------------------------------------------------- /tools/multiplex/tests/custom_data_storage/second-tool.h: -------------------------------------------------------------------------------- 1 | #define CLIENT_TOOL_LIBRARIES_VAR "PRINT_EMBEDDED_TOOL_LIBRARIES" 2 | #include "ompt-multiplex.h" 3 | #define _TOOL_PREFIX " second_tool:" 4 | #include "callback.h" 5 | #undef _TOOL_PREFIX 6 | -------------------------------------------------------------------------------- /tools/multiplex/tests/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @AUTO_GEN_COMMENT@ 2 | 3 | config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" 4 | config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" 5 | config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ 6 | config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" 7 | config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" 8 | config.test_extra_flags = "@OPENMP_TEST_FLAGS@" 9 | config.test_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" 10 | config.omp_library_dir = "@LIBOMP_LIBRARY_DIR@" 11 | config.omp_header_dir = "@LIBOMP_INCLUDE_DIR@" 12 | config.ompt_print_callback_dir = "@OMPT_PRINT_CALLBACKS_DIR@" 13 | config.operating_system = "@CMAKE_SYSTEM_NAME@" 14 | 15 | # Let the main config do the real work. 16 | lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") 17 | -------------------------------------------------------------------------------- /tools/multiplex/tests/ompt-signal.h: -------------------------------------------------------------------------------- 1 | // These functions are used to provide a signal-wait mechanism to enforce 2 | // expected scheduling for the test cases. Conditional variable (s) needs to be 3 | // shared! Initialize to 0 4 | #include 5 | 6 | #define OMPT_SIGNAL(s) ompt_signal(&s) 7 | // inline 8 | void ompt_signal(int *s) { 9 | #pragma omp atomic 10 | (*s)++; 11 | } 12 | 13 | #define OMPT_WAIT(s, v) ompt_wait(&s, v) 14 | // wait for s >= v 15 | // inline 16 | void ompt_wait(int *s, int v) { 17 | int wait = 0; 18 | do { 19 | usleep(10); 20 | #pragma omp atomic read 21 | wait = (*s); 22 | } while (wait < v); 23 | } 24 | -------------------------------------------------------------------------------- /tools/multiplex/tests/print/first-tool.h: -------------------------------------------------------------------------------- 1 | #define CLIENT_TOOL_LIBRARIES_VAR "PRINT_TOOL_LIBRARIES" 2 | #include "ompt-multiplex.h" 3 | #define _TOOL_PREFIX " _first_tool:" 4 | #include "callback.h" 5 | #undef _TOOL_PREFIX 6 | -------------------------------------------------------------------------------- /tools/multiplex/tests/print/second-tool.h: -------------------------------------------------------------------------------- 1 | #define CLIENT_TOOL_LIBRARIES_VAR "PRINT_EMBEDDED_TOOL_LIBRARIES" 2 | #include "ompt-multiplex.h" 3 | #define _TOOL_PREFIX " second_tool:" 4 | #include "callback.h" 5 | #undef _TOOL_PREFIX 6 | -------------------------------------------------------------------------------- /www/Reference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmodels/bolt/c1dc0e6e6ff6355319efa8f6c1dde7f02031afbf/www/Reference.pdf -------------------------------------------------------------------------------- /www/content.css: -------------------------------------------------------------------------------- 1 | html { margin: 0px; } body { margin: 8px; } 2 | 3 | html, body { 4 | padding:0px; 5 | font-size:small; font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, Helvetica, sans-serif; background-color: #fff; color: #222; 6 | line-height:1.5; 7 | } 8 | 9 | h1, h2, h3, tt { color: #000 } 10 | 11 | h1 { padding-top:0px; margin-top:0px;} 12 | h2 { color:#333333; padding-top:0.5em; } 13 | h3 { padding-top: 0.5em; margin-bottom: -0.25em; color:#2d58b7} 14 | li { padding-bottom: 0.5em; } 15 | ul { padding-left:1.5em; } 16 | 17 | /* Slides */ 18 | IMG.img_slide { 19 | display: block; 20 | margin-left: auto; 21 | margin-right: auto 22 | } 23 | 24 | .itemTitle { color:#2d58b7 } 25 | 26 | /* Tables */ 27 | tr { vertical-align:top } 28 | -------------------------------------------------------------------------------- /www/menu.css: -------------------------------------------------------------------------------- 1 | /***************/ 2 | /* page layout */ 3 | /***************/ 4 | 5 | [id=menu] { 6 | position:fixed; 7 | width:25ex; 8 | } 9 | [id=content] { 10 | /* ***** EDIT THIS VALUE IF CONTENT OVERLAPS MENU ***** */ 11 | position:absolute; 12 | left:29ex; 13 | padding-right:4ex; 14 | } 15 | 16 | /**************/ 17 | /* menu style */ 18 | /**************/ 19 | 20 | #menu .submenu { 21 | padding-top:1em; 22 | display:block; 23 | } 24 | 25 | #menu label { 26 | display:block; 27 | font-weight: bold; 28 | text-align: center; 29 | background-color: rgb(192,192,192); 30 | } 31 | #menu a { 32 | padding:0 .2em; 33 | display:block; 34 | text-align: center; 35 | background-color: rgb(235,235,235); 36 | } 37 | #menu a:visited { 38 | color:rgb(100,50,100); 39 | } 40 | --------------------------------------------------------------------------------