Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
602b5ba4
Commit
602b5ba4
authored
12 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
update onelab automatic build (in dg build system)
parent
8b29e5da
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/onelab/Makefile
+1
-1
1 addition, 1 deletion
contrib/onelab/Makefile
contrib/onelab/myOS.cpp
+216
-0
216 additions, 0 deletions
contrib/onelab/myOS.cpp
contrib/onelab/myOS.h
+24
-0
24 additions, 0 deletions
contrib/onelab/myOS.h
with
241 additions
and
1 deletion
contrib/onelab/Makefile
+
1
−
1
View file @
602b5ba4
...
...
@@ -2,7 +2,7 @@ SOLVERS=loader
SOURCES
=
myOS StringUtils mathex OnelabClients OnelabMessage OnelabParser metamodel
COMMON_DIR
=
$(
GMSH_DIR
)
/Common
ONELAB_DIR
=
$(
GMSH_DIR
)
/
projects
/onelab
ONELAB_DIR
=
$(
GMSH_DIR
)
/
contrib
/onelab
MATHEX_DIR
=
$(
GMSH_DIR
)
/contrib/MathEx
OBJDIR
=
objects
...
...
This diff is collapsed.
Click to expand it.
contrib/onelab/myOS.cpp
0 → 100644
+
216
−
0
View file @
602b5ba4
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
// This file contains a bunch of functions that depend on OS-dependent
// features and/or system calls
// these are available on all OSes
#include
<stdlib.h>
#include
<stdio.h>
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<signal.h>
#include
<time.h>
#include
<math.h>
#if !defined(WIN32) || defined(__CYGWIN__)
#include
<unistd.h>
#include
<sys/time.h>
#include
<sys/resource.h>
#endif
#if defined(WIN32)
#include
<windows.h>
#include
<process.h>
#include
<io.h>
#endif
#if defined(__APPLE__)
#define RUSAGE_SELF 0
#define RUSAGE_CHILDREN -1
#endif
//#include "GmshMessage.h"
#include
"OnelabMessage.h"
const
char
*
GetEnvironmentVar
(
const
char
*
var
)
{
#if !defined(WIN32)
return
getenv
(
var
);
#else
const
char
*
tmp
=
getenv
(
var
);
// Don't accept top dir or anything partially expanded like
// c:\Documents and Settings\%USERPROFILE%, etc.
if
(
!
tmp
||
!
strcmp
(
tmp
,
"/"
)
||
strstr
(
tmp
,
"%"
)
||
strstr
(
tmp
,
"$"
))
return
0
;
else
return
tmp
;
#endif
}
double
GetTimeInSeconds
()
{
#if !defined(WIN32) || defined(__CYGWIN__)
struct
timeval
tp
;
gettimeofday
(
&
tp
,
(
struct
timezone
*
)
0
);
double
t
=
(
double
)
tp
.
tv_sec
+
1.e-6
*
(
double
)
tp
.
tv_usec
;
return
t
;
#else
FILETIME
ft
;
GetSystemTimeAsFileTime
(
&
ft
);
double
t
=
1.e-7
*
4294967296.
*
(
double
)
ft
.
dwHighDateTime
+
1.e-7
*
(
double
)
ft
.
dwLowDateTime
;
return
t
;
#endif
}
void
SleepInSeconds
(
double
s
)
{
#if !defined(WIN32) || defined(__CYGWIN__)
usleep
((
long
)(
1.e6
*
s
));
#else
Sleep
((
long
)(
1.e3
*
s
));
#endif
}
static
void
GetResources
(
double
*
s
,
long
*
mem
)
{
#if !defined(WIN32) || defined(__CYGWIN__)
static
struct
rusage
r
;
getrusage
(
RUSAGE_SELF
,
&
r
);
*
s
=
(
double
)
r
.
ru_utime
.
tv_sec
+
1.e-6
*
(
double
)
r
.
ru_utime
.
tv_usec
;
*
mem
=
(
long
)
r
.
ru_maxrss
;
#else
FILETIME
creation
,
exit
,
kernel
,
user
;
if
(
GetProcessTimes
(
GetCurrentProcess
(),
&
creation
,
&
exit
,
&
kernel
,
&
user
)){
*
s
=
1.e-7
*
4294967296.
*
(
double
)
user
.
dwHighDateTime
+
1.e-7
*
(
double
)
user
.
dwLowDateTime
;
}
*
mem
=
0
;
#endif
}
void
CheckResources
()
{
#if !defined (WIN32) || defined(__CYGWIN__)
static
struct
rlimit
r
;
getrlimit
(
RLIMIT_STACK
,
&
r
);
// Try to get at least 16 MB of stack. Running with too small a stack
// can cause crashes in the recursive calls (e.g. for tet
// classification in 3D Delaunay)
if
(
r
.
rlim_cur
<
16
*
1024
*
1024
){
OLMsg
::
Info
(
"Increasing process stack size (%d kB < 16 MB)"
,
r
.
rlim_cur
/
1024
);
r
.
rlim_cur
=
r
.
rlim_max
;
setrlimit
(
RLIMIT_STACK
,
&
r
);
}
#endif
}
double
Cpu
()
{
long
mem
=
0
;
double
s
=
0.
;
GetResources
(
&
s
,
&
mem
);
return
s
;
}
long
GetMemoryUsage
()
{
long
mem
=
0
;
double
s
=
0.
;
GetResources
(
&
s
,
&
mem
);
return
mem
;
}
int
GetProcessId
()
{
#if !defined(WIN32) || defined(__CYGWIN__)
return
getpid
();
#else
return
_getpid
();
#endif
}
std
::
string
GetHostName
()
{
char
host
[
256
];
gethostname
(
host
,
sizeof
(
host
));
return
std
::
string
(
host
);
}
int
UnlinkFile
(
const
std
::
string
&
fileName
)
{
#if !defined(WIN32) || defined(__CYGWIN__)
return
unlink
(
fileName
.
c_str
());
#else
return
_unlink
(
fileName
.
c_str
());
#endif
}
int
StatFile
(
const
std
::
string
&
fileName
)
{
#if !defined(WIN32) || defined(__CYGWIN__)
struct
stat
buf
;
return
stat
(
fileName
.
c_str
(),
&
buf
);
#else
struct
_stat
buf
;
return
_stat
(
fileName
.
c_str
(),
&
buf
);
#endif
}
int
KillProcess
(
int
pid
)
{
#if !defined(WIN32) || defined(__CYGWIN__)
if
(
kill
(
pid
,
9
))
return
0
;
#else
HANDLE
hProc
=
OpenProcess
(
PROCESS_TERMINATE
,
FALSE
,
pid
);
if
(
!
TerminateProcess
(
hProc
,
0
)){
CloseHandle
(
hProc
);
return
0
;
}
#endif
return
1
;
}
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
)
{
#if defined(WIN32)
STARTUPINFO
suInfo
;
PROCESS_INFORMATION
prInfo
;
memset
(
&
suInfo
,
0
,
sizeof
(
suInfo
));
suInfo
.
cb
=
sizeof
(
suInfo
);
OLMsg
::
Info
(
"Calling '%s'"
,
command
.
c_str
());
if
(
blocking
){
CreateProcess
(
NULL
,
(
char
*
)
command
.
c_str
(),
NULL
,
NULL
,
FALSE
,
NORMAL_PRIORITY_CLASS
,
NULL
,
NULL
,
&
suInfo
,
&
prInfo
);
// wait until child process exits.
WaitForSingleObject
(
prInfo
.
hProcess
,
INFINITE
);
// close process and thread handles.
CloseHandle
(
prInfo
.
hProcess
);
CloseHandle
(
prInfo
.
hThread
);
}
else
{
// DETACHED_PROCESS removes the console (useful if the program to launch is
// a console-mode exe)
CreateProcess
(
NULL
,
(
char
*
)
command
.
c_str
(),
NULL
,
NULL
,
FALSE
,
NORMAL_PRIORITY_CLASS
|
DETACHED_PROCESS
,
NULL
,
NULL
,
&
suInfo
,
&
prInfo
);
}
return
0
;
#else
if
(
!
system
(
NULL
))
{
OLMsg
::
Error
(
"Could not find /bin/sh: aborting system call"
);
return
1
;
}
std
::
string
cmd
(
command
);
if
(
!
blocking
)
cmd
+=
" &"
;
OLMsg
::
Info
(
"Calling '%s'"
,
cmd
.
c_str
());
return
system
(
cmd
.
c_str
());
#endif
}
This diff is collapsed.
Click to expand it.
contrib/onelab/myOS.h
0 → 100644
+
24
−
0
View file @
602b5ba4
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#ifndef _OS_H_
#define _OS_H_
#include
<string>
const
char
*
GetEnvironmentVar
(
const
char
*
var
);
double
GetTimeInSeconds
();
void
SleepInSeconds
(
double
s
);
void
CheckResources
();
double
Cpu
();
long
GetMemoryUsage
();
int
GetProcessId
();
std
::
string
GetHostName
();
int
UnlinkFile
(
const
std
::
string
&
fileName
);
int
StatFile
(
const
std
::
string
&
fileName
);
int
KillProcess
(
int
pid
);
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
=
false
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment