diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports --- a/openmp/runtime/src/dllexports +++ b/openmp/runtime/src/dllexports @@ -390,8 +390,9 @@ __kmpc_taskred_init 277 __kmpc_taskred_modifier_init 278 __kmpc_omp_target_task_alloc 279 + __kmpc_error 281 __kmpc_masked 282 - __kmpc_end_masked 283 + __kmpc_end_masked 283 %endif # User API entry points that have both lower- and upper- case versions for Fortran. diff --git a/openmp/runtime/src/i18n/en_US.txt b/openmp/runtime/src/i18n/en_US.txt --- a/openmp/runtime/src/i18n/en_US.txt +++ b/openmp/runtime/src/i18n/en_US.txt @@ -455,6 +455,8 @@ AffUseGlobCpuidL "%1$s: Affinity capable, using global cpuid leaf %2$d info" AffNotCapableUseLocCpuidL "%1$s: Affinity not capable, using local cpuid leaf %2$d info" AffNotUsingHwloc "%1$s: Affinity not capable, using hwloc." +UserDirectedError "Encountered user-directed error: %1$s." +UserDirectedWarning "Encountered user-directed warning: %1$s." FailedToCreateTeam "Failed to create teams between lower bound (%1$d) and upper bound (%2$d)." # -------------------------------------------------------------------------------------------------- diff --git a/openmp/runtime/src/include/omp-tools.h.var b/openmp/runtime/src/include/omp-tools.h.var --- a/openmp/runtime/src/include/omp-tools.h.var +++ b/openmp/runtime/src/include/omp-tools.h.var @@ -1099,6 +1099,13 @@ const void *codeptr_ra ); +typedef struct ompt_record_error_t { + ompt_severity_t severity; + const char *message; + size_t length; + const void *codeptr_ra; +} ompt_record_error_t; + typedef struct ompd_address_t { ompd_seg_t segment; ompd_addr_t address; diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -4088,6 +4088,13 @@ #define KMP_GTID_TO_SHADOW_GTID(gtid) \ ((gtid) % (__kmp_hidden_helper_threads_num - 1) + 2) +// Support for error directive +typedef enum kmp_severity_t { + severity_warning = 1, + severity_fatal = 2 +} kmp_severity_t; +extern void __kmpc_error(int severity, const char *message); + #ifdef __cplusplus } #endif diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -4357,3 +4357,23 @@ } return __kmp_pause_resource(level); } + +void __kmpc_error(int severity, const char *message) { + if (!__kmp_init_serial) + __kmp_serial_initialize(); + + KMP_ASSERT(severity == severity_warning || severity == severity_fatal); + +#if OMPT_SUPPORT + if (ompt_enabled.enabled && ompt_enabled.ompt_callback_error) { + ompt_callbacks.ompt_callback(ompt_callback_error)( + (ompt_severity_t)severity, message, KMP_STRLEN(message), + OMPT_GET_RETURN_ADDRESS(0)); + } +#endif // OMPT_SUPPORT + + if (severity == severity_warning) + KMP_WARNING(UserDirectedWarning, message); + else + KMP_FATAL(UserDirectedError, message); +} diff --git a/openmp/runtime/src/ompt-event-specific.h b/openmp/runtime/src/ompt-event-specific.h --- a/openmp/runtime/src/ompt-event-specific.h +++ b/openmp/runtime/src/ompt-event-specific.h @@ -106,6 +106,6 @@ #define ompt_callback_dispatch_implemented ompt_event_UNIMPLEMENTED -#define ompt_callback_error_implemented ompt_event_UNIMPLEMENTED +#define ompt_callback_error_implemented ompt_event_MAY_ALWAYS_OPTIONAL #endif