[Openmp-commits] [openmp] r227469 - Pin the libiomp5.dll for the lifetime of application, Windows-specific

Andrey Churbanov Andrey.Churbanov at intel.com
Thu Jan 29 09:18:20 PST 2015


Author: achurbanov
Date: Thu Jan 29 11:18:20 2015
New Revision: 227469

URL: http://llvm.org/viewvc/llvm-project?rev=227469&view=rev
Log:
Pin the libiomp5.dll for the lifetime of application, Windows-specific

Modified:
    openmp/trunk/runtime/src/z_Windows_NT_util.c

Modified: openmp/trunk/runtime/src/z_Windows_NT_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Windows_NT_util.c?rev=227469&r1=227468&r2=227469&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Windows_NT_util.c (original)
+++ openmp/trunk/runtime/src/z_Windows_NT_util.c Thu Jan 29 11:18:20 2015
@@ -835,6 +835,21 @@ __kmp_runtime_initialize( void )
         return;
     };
 
+#if GUIDEDLL_EXPORTS
+    /* Pin dynamic library for the lifetime of application */
+    {
+        // First, turn off error message boxes
+        UINT err_mode = SetErrorMode (SEM_FAILCRITICALERRORS);
+        HMODULE h;
+        BOOL ret = GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
+                                     |GET_MODULE_HANDLE_EX_FLAG_PIN,
+                                     (LPCTSTR)&__kmp_serial_initialize, &h);
+        KMP_DEBUG_ASSERT2(h && ret, "OpenMP RTL cannot find itself loaded");
+        SetErrorMode (err_mode);   // Restore error mode
+        KA_TRACE( 10, ("__kmp_runtime_initialize: dynamic library pinned\n") );
+    }
+#endif
+
     InitializeCriticalSection( & __kmp_win32_section );
 #if USE_ITT_BUILD
     __kmp_itt_system_object_created( & __kmp_win32_section, "Critical Section" );





More information about the Openmp-commits mailing list