From 306035adee1dfe790dfb279231e03db35e128512 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 9 May 2009 09:48:16 +0000 Subject: [PATCH] RunParallel in nginterface --- libsrc/include/nginterface.h | 1 + ng/nginterface.cpp | 78 +++++++++++++++++-- ng/ngpkg.cpp | 146 ++++++++++++++++++----------------- ng/variables.tcl | 5 +- 4 files changed, 152 insertions(+), 78 deletions(-) diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 91550a46..100585f0 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -344,6 +344,7 @@ extern "C" { // pairs should be an integer array of 2*npairs DLL_HEADER void Ng_GetPeriodicEdges (int idnr, int * pairs); + DLL_HEADER void RunParallel ( void * (*fun)(void *), void * in); DLL_HEADER void Ng_PushStatus (const char * str); DLL_HEADER void Ng_PopStatus (); diff --git a/ng/nginterface.cpp b/ng/nginterface.cpp index a84ecf98..0b81fbed 100644 --- a/ng/nginterface.cpp +++ b/ng/nginterface.cpp @@ -68,14 +68,82 @@ namespace netgen using namespace netgen; + /* - extern void * operator new (size_t s); - extern void * operator new [] (size_t s); - extern void operator delete (void * p); - extern void operator delete [] (void * p); + +#ifdef _MSC_VER +// Philippose - 30/01/2009 +// MSVC Express Edition Support +#ifdef MSVC_EXPRESS + +// #include + + static pthread_t meshingthread; + void RunParallel ( void * (*fun)(void *), void * in) + { + if (netgen::mparam.parthread) + { + pthread_attr_t attr; + pthread_attr_init (&attr); + // the following call can be removed if not available: + pthread_attr_setstacksize(&attr, 1000000); + //pthread_create (&meshingthread, &attr, fun, NULL); + pthread_create (&meshingthread, &attr, fun, in); + } + else + fun (in); + } + +#else // Using MS VC++ Standard / Enterprise / Professional edition + + // Afx - Threads need different return - value: + + static void* (*sfun)(void *); + unsigned int fun2 (void * val) + { + sfun (val); + return 0; + } + + void RunParallel ( void* (*fun)(void *), void * in) + { + sfun = fun; + if (netgen::mparam.parthread) + AfxBeginThread (fun2, in); + //AfxBeginThread (fun2, NULL); + else + fun (in); + } + +#endif // #ifdef MSVC_EXPRESS + +#else // For #ifdef _MSC_VER + +// #include + + static pthread_t meshingthread; + void RunParallel ( void * (*fun)(void *), void * in) + { + if (netgen::mparam.parthread) + { + pthread_attr_t attr; + pthread_attr_init (&attr); + // the following call can be removed if not available: + pthread_attr_setstacksize(&attr, 1000000); + //pthread_create (&meshingthread, &attr, fun, NULL); + pthread_create (&meshingthread, &attr, fun, in); + } + else + fun (in); + } + +#endif // #ifdef _MSC_VER + + */ -// extern FlexLexer * lexer; + + diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index 65fa3a05..037a7ed6 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -45,6 +45,82 @@ The interface between the GUI and the netgen library extern bool nodisplay; + +#include + + + +#ifdef _MSC_VER +// Philippose - 30/01/2009 +// MSVC Express Edition Support +#ifdef MSVC_EXPRESS + +// #include + + static pthread_t meshingthread; + void RunParallel ( void * (*fun)(void *), void * in) + { + if (netgen::mparam.parthread) + { + pthread_attr_t attr; + pthread_attr_init (&attr); + // the following call can be removed if not available: + pthread_attr_setstacksize(&attr, 1000000); + //pthread_create (&meshingthread, &attr, fun, NULL); + pthread_create (&meshingthread, &attr, fun, in); + } + else + fun (in); + } + +#else // Using MS VC++ Standard / Enterprise / Professional edition + + // Afx - Threads need different return - value: + + static void* (*sfun)(void *); + unsigned int fun2 (void * val) + { + sfun (val); + return 0; + } + + void RunParallel ( void* (*fun)(void *), void * in) + { + sfun = fun; + if (netgen::mparam.parthread) + AfxBeginThread (fun2, in); + //AfxBeginThread (fun2, NULL); + else + fun (in); + } + +#endif // #ifdef MSVC_EXPRESS + +#else // For #ifdef _MSC_VER + +// #include + + static pthread_t meshingthread; + void RunParallel ( void * (*fun)(void *), void * in) + { + if (netgen::mparam.parthread) + { + pthread_attr_t attr; + pthread_attr_init (&attr); + // the following call can be removed if not available: + pthread_attr_setstacksize(&attr, 1000000); + //pthread_create (&meshingthread, &attr, fun, NULL); + pthread_create (&meshingthread, &attr, fun, in); + } + else + fun (in); + } + +#endif // #ifdef _MSC_VER + + + + namespace netgen { #include "../libsrc/interface/writeuser.hpp" @@ -173,76 +249,6 @@ namespace netgen -#ifdef _MSC_VER -// Philippose - 30/01/2009 -// MSVC Express Edition Support -#ifdef MSVC_EXPRESS - -// #include - - static pthread_t meshingthread; - void RunParallel ( void * (*fun)(void *), void * in) - { - if (mparam.parthread) - { - pthread_attr_t attr; - pthread_attr_init (&attr); - // the following call can be removed if not available: - pthread_attr_setstacksize(&attr, 1000000); - //pthread_create (&meshingthread, &attr, fun, NULL); - pthread_create (&meshingthread, &attr, fun, in); - } - else - fun (in); - } - -#else // Using MS VC++ Standard / Enterprise / Professional edition - - // Afx - Threads need different return - value: - - static void* (*sfun)(void *); - unsigned int fun2 (void * val) - { - sfun (val); - return 0; - } - - void RunParallel ( void* (*fun)(void *), void * in) - { - sfun = fun; - if (mparam.parthread) - AfxBeginThread (fun2, in); - //AfxBeginThread (fun2, NULL); - else - fun (in); - } - -#endif // #ifdef MSVC_EXPRESS - -#else // For #ifdef _MSC_VER - -// #include - - static pthread_t meshingthread; - void RunParallel ( void * (*fun)(void *), void * in) - { - if (mparam.parthread) - { - pthread_attr_t attr; - pthread_attr_init (&attr); - // the following call can be removed if not available: - pthread_attr_setstacksize(&attr, 1000000); - //pthread_create (&meshingthread, &attr, fun, NULL); - pthread_create (&meshingthread, &attr, fun, in); - } - else - fun (in); - } - -#endif // #ifdef _MSC_VER - - - #ifndef SMALLLIB // Destination for messages, errors, ... void Ng_PrintDest(const char * s) diff --git a/ng/variables.tcl b/ng/variables.tcl index a11ef096..cb77d311 100644 --- a/ng/variables.tcl +++ b/ng/variables.tcl @@ -260,10 +260,10 @@ set optlist { } -set visoptions.usetexture 0 +set visoptions.usetexture 1 set visoptions.invcolor 0 set visoptions.imaginary 0 -set visoptions.lineartexture 1 +set visoptions.lineartexture 0 set visoptions.numtexturecols 16 set visoptions.showclipsolution 1 set visoptions.showsurfacesolution 0 @@ -322,7 +322,6 @@ set visoptions.gridsize 20 set visoptions.xoffset 0 set visoptions.yoffset 0 set visoptions.autoscale 1 -set visoptions.lineartexture 1 set visoptions.redrawperiodic 0 set visoptions.logscale 0 set visoptions.mminval 0