Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
083fb863
Commit
083fb863
authored
16 years ago
by
John Romein
Browse files
Options
Downloads
Patches
Plain Diff
bug 225:
map flat memory.
parent
c3a42a4b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
RTCP/IONProc/src/ION_main.cc
+30
-57
30 additions, 57 deletions
RTCP/IONProc/src/ION_main.cc
with
30 additions
and
57 deletions
RTCP/IONProc/src/ION_main.cc
+
30
−
57
View file @
083fb863
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include
<Interface/CN_Mapping.h>
#include
<Interface/CN_Mapping.h>
#include
<Interface/Parset.h>
#include
<Interface/Parset.h>
#include
<Interface/Exceptions.h>
#include
<Interface/Exceptions.h>
#include
<ION_Allocator.h>
#include
<InputSection.h>
#include
<InputSection.h>
#include
<OutputSection.h>
#include
<OutputSection.h>
#include
<Stream/FileStream.h>
#include
<Stream/FileStream.h>
...
@@ -296,71 +297,42 @@ static void ignoreSigPipe()
...
@@ -296,71 +297,42 @@ static void ignoreSigPipe()
}
}
#ifdef FLAT_MEMORY
#if defined FLAT_MEMORY
static
void
cat
(
const
char
*
fn
)
{
static
void
*
flatMemoryAddress
=
reinterpret_cast
<
void
*>
(
0x50000000
);
FILE
*
fp
;
static
size_t
flatMemorySize
=
1536
*
1024
*
1024
;
char
buf
[
256
];
printf
(
"[%s]
\n
"
,
fn
);
fp
=
fopen
(
fn
,
"r"
);
if
(
!
fp
)
{
fprintf
(
stderr
,
"Fail to open %s
\n
"
,
fn
);
exit
(
1
);
}
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
0
)
{
printf
(
"%s"
,
buf
);
}
fclose
(
fp
);
}
static
void
*
mmapFa
s
tMemory
()
static
void
mmapF
l
atMemory
()
/*
/*
mmap a fixed area of flat memory space to increase performance.
mmap a fixed area of flat memory space to increase performance.
currently only
768 M
iB can be allocated, we mmap() the maximum
currently only
1.5 G
iB can be allocated, we mmap() the maximum
available amount
available amount
*/
*/
{
{
unsigned
size
=
0
;
int
fd
=
open
(
"/dev/flatmem"
,
O_RDONLY
);
char
buf
[
80
];
FILE
*
fp
;
int
fd
;
void
*
flatmem_mmap_addr
;
fp
=
fopen
(
"/proc/meminfo"
,
"r"
);
if
(
!
fp
)
{
perror
(
"fopen"
);
exit
(
1
);
}
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
(
char
*
)
0
)
{
if
(
strstr
(
buf
,
"FlatMem:"
)
)
{
char
*
p
=
strtok
(
buf
,
"
\t\n
"
);
p
=
strtok
(
NULL
,
"
\t\n
"
);
size
=
atoi
(
p
)
*
1024
*
1024
;
break
;
}
}
fclose
(
fp
);
/* get flatmem address */
if
(
fd
<
0
)
{
fd
=
open
(
"/dev/flatmem"
,
O_RDONLY
);
perror
(
"open(
\"
/dev/flatmem
\"
, O_RDONLY)"
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"/dev/flatmem does not exist
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
/* 0x40000000 is usually the lowest virtual address of free vm start in 256MB alignment */
if
(
mmap
(
flatMemoryAddress
,
flatMemorySize
,
PROT_READ
,
MAP_PRIVATE
|
MAP_FIXED
,
fd
,
0
)
==
MAP_FAILED
)
{
flatmem_mmap_addr
=
mmap
((
void
*
)
0x50000000
,
size
,
PROT_READ
,
MAP_PRIVATE
,
fd
,
0
);
perror
(
"mmap flat memory"
);
if
(
flatmem_mmap_addr
==
MAP_FAILED
)
{
perror
(
"mmap"
);
exit
(
1
);
exit
(
1
);
}
}
cat
(
"/proc/self/maps"
);
close
(
fd
);
std
::
clog
<<
"mapped "
<<
flatMemorySize
<<
" bytes of fast memory at "
<<
flatMemoryAddress
<<
std
::
endl
;
}
return
flatmem_mmap_addr
;
static
void
unmapFlatMemory
()
{
if
(
munmap
(
flatMemoryAddress
,
flatMemorySize
)
<
0
)
perror
(
"munmap flat memory"
);
}
}
#endif
#endif
void
*
master_thread
(
void
*
)
void
*
master_thread
(
void
*
)
...
@@ -373,14 +345,11 @@ void *master_thread(void *)
...
@@ -373,14 +345,11 @@ void *master_thread(void *)
enableCoreDumps
();
enableCoreDumps
();
ignoreSigPipe
();
ignoreSigPipe
();
#ifdef FLAT_MEMORY
try
{
void
*
flatmem_addr
=
mmapFastMemory
();
#if defined FLAT_MEMORY
mmapFlatMemory
();
std
::
clog
<<
"Flatmem base address : "
<<
flatmem_addr
<<
std
::
endl
;
#endif
#endif
try
{
setenv
(
"AIPSPATH"
,
"/cephome/romein/packages/casacore-0.3.0/stage/"
,
0
);
// FIXME
setenv
(
"AIPSPATH"
,
"/cephome/romein/packages/casacore-0.3.0/stage/"
,
0
);
// FIXME
pthread_t
input_thread_id
,
output_thread_id
;
pthread_t
input_thread_id
,
output_thread_id
;
...
@@ -449,6 +418,10 @@ void *master_thread(void *)
...
@@ -449,6 +418,10 @@ void *master_thread(void *)
std
::
clog
<<
"lofar__fini: output thread joined"
<<
std
::
endl
;
std
::
clog
<<
"lofar__fini: output thread joined"
<<
std
::
endl
;
}
}
#if defined FLAT_MEMORY
unmapFlatMemory
();
#endif
}
catch
(
Exception
&
ex
)
{
}
catch
(
Exception
&
ex
)
{
std
::
cerr
<<
"main thread caught Exception: "
<<
ex
<<
std
::
endl
;
std
::
cerr
<<
"main thread caught Exception: "
<<
ex
<<
std
::
endl
;
}
catch
(
std
::
exception
&
ex
)
{
}
catch
(
std
::
exception
&
ex
)
{
...
...
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