RunParallel in nginterface

This commit is contained in:
Joachim Schoeberl 2009-05-09 09:48:16 +00:00
parent 1c7f2356e0
commit 306035adee
4 changed files with 152 additions and 78 deletions

View File

@ -344,6 +344,7 @@ extern "C" {
// pairs should be an integer array of 2*npairs // pairs should be an integer array of 2*npairs
DLL_HEADER void Ng_GetPeriodicEdges (int idnr, int * pairs); 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_PushStatus (const char * str);
DLL_HEADER void Ng_PopStatus (); DLL_HEADER void Ng_PopStatus ();

View File

@ -68,14 +68,82 @@ namespace netgen
using namespace netgen; using namespace netgen;
/* /*
extern void * operator new (size_t s);
extern void * operator new [] (size_t s); #ifdef _MSC_VER
extern void operator delete (void * p); // Philippose - 30/01/2009
extern void operator delete [] (void * p); // MSVC Express Edition Support
#ifdef MSVC_EXPRESS
// #include <pthread.h>
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 <pthread.h>
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;

View File

@ -45,6 +45,82 @@ The interface between the GUI and the netgen library
extern bool nodisplay; extern bool nodisplay;
#include <nginterface.h>
#ifdef _MSC_VER
// Philippose - 30/01/2009
// MSVC Express Edition Support
#ifdef MSVC_EXPRESS
// #include <pthread.h>
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 <pthread.h>
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 namespace netgen
{ {
#include "../libsrc/interface/writeuser.hpp" #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 <pthread.h>
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 <pthread.h>
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 #ifndef SMALLLIB
// Destination for messages, errors, ... // Destination for messages, errors, ...
void Ng_PrintDest(const char * s) void Ng_PrintDest(const char * s)

View File

@ -260,10 +260,10 @@ set optlist {
} }
set visoptions.usetexture 0 set visoptions.usetexture 1
set visoptions.invcolor 0 set visoptions.invcolor 0
set visoptions.imaginary 0 set visoptions.imaginary 0
set visoptions.lineartexture 1 set visoptions.lineartexture 0
set visoptions.numtexturecols 16 set visoptions.numtexturecols 16
set visoptions.showclipsolution 1 set visoptions.showclipsolution 1
set visoptions.showsurfacesolution 0 set visoptions.showsurfacesolution 0
@ -322,7 +322,6 @@ set visoptions.gridsize 20
set visoptions.xoffset 0 set visoptions.xoffset 0
set visoptions.yoffset 0 set visoptions.yoffset 0
set visoptions.autoscale 1 set visoptions.autoscale 1
set visoptions.lineartexture 1
set visoptions.redrawperiodic 0 set visoptions.redrawperiodic 0
set visoptions.logscale 0 set visoptions.logscale 0
set visoptions.mminval 0 set visoptions.mminval 0