mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
RunParallel in nginterface
This commit is contained in:
parent
1c7f2356e0
commit
306035adee
@ -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 ();
|
||||
|
@ -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 <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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
146
ng/ngpkg.cpp
146
ng/ngpkg.cpp
@ -45,6 +45,82 @@ The interface between the GUI and the netgen library
|
||||
|
||||
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
|
||||
{
|
||||
#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
|
||||
// Destination for messages, errors, ...
|
||||
void Ng_PrintDest(const char * s)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user