Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
aa2ac201
Commit
aa2ac201
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Implement calculation of memory requirements for trapping
parent
1ac18b52
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/include/tfrfme.h
+29
-0
29 additions, 0 deletions
src/include/tfrfme.h
src/libnptm/tfrfme.cpp
+24
-0
24 additions, 0 deletions
src/libnptm/tfrfme.cpp
src/make.inc
+2
-2
2 additions, 2 deletions
src/make.inc
src/trapping/cfrfme.cpp
+14
-0
14 additions, 0 deletions
src/trapping/cfrfme.cpp
with
69 additions
and
2 deletions
src/include/tfrfme.h
+
29
−
0
View file @
aa2ac201
...
@@ -69,6 +69,13 @@ public:
...
@@ -69,6 +69,13 @@ public:
*/
*/
std
::
complex
<
double
>
get_element
(
int
index
)
{
return
wk
[
index
];
}
std
::
complex
<
double
>
get_element
(
int
index
)
{
return
wk
[
index
];
}
/*! \brief Calculate the necessary amount of memory to create a new instance.
*
* \param lm: `int` Maximum field expansion order.
* \return size: `long` The necessary memory size in bytes.
*/
static
long
get_memory_requirement
(
int
lm
);
/*! \brief Set an element in the WK vector.
/*! \brief Set an element in the WK vector.
*
*
* \param index: `int` Index of the desired element.
* \param index: `int` Index of the desired element.
...
@@ -185,6 +192,13 @@ public:
...
@@ -185,6 +192,13 @@ public:
*/
*/
double
get_matrix_element
(
int
row
,
int
col
)
{
return
vkzm
[
row
][
col
];
}
double
get_matrix_element
(
int
row
,
int
col
)
{
return
vkzm
[
row
][
col
];
}
/*! \brief Calculate the necessary amount of memory to create a new instance.
*
* \param _nkv: `int` Number of radial vector coordinates. QUESTION: correct?
* \return size: `long` The necessary memory size in bytes.
*/
static
long
get_memory_requirement
(
int
_nkv
);
/*! \brief Get a parameter by its name.
/*! \brief Get a parameter by its name.
*
*
* \param param_name: `string` Name of the parameter.
* \param param_name: `string` Name of the parameter.
...
@@ -349,6 +363,21 @@ public:
...
@@ -349,6 +363,21 @@ public:
*/
*/
std
::
complex
<
double
>
get_matrix_element
(
int
row
,
int
col
);
std
::
complex
<
double
>
get_matrix_element
(
int
row
,
int
col
);
/*! \brief Calculate the necessary amount of memory to create a new instance.
*
* \param _lmode: `int` Order expansion mode flag.
* \param _lm: `int` Maximum field expansion order.
* \param _nkv: `int` Number of radial vector coordinates. QUESTION: correct?
* \param _nxv: `int` Number of computed X coordinates.
* \param _nyv: `int` Number of computed Y coordinates.
* \param _nzv: `int` Number of computed Z coordinates.
* \return size: `long` The necessary memory size in bytes.
*/
static
long
get_memory_requirement
(
int
_lmode
,
int
_lm
,
int
_nkv
,
int
_nxv
,
int
_nyv
,
int
_nzv
);
/*! \brief Get a configuration parameter.
/*! \brief Get a configuration parameter.
*
*
* \param param_name: `string` Name of the parameter.
* \param param_name: `string` Name of the parameter.
...
...
This diff is collapsed.
Click to expand it.
src/libnptm/tfrfme.cpp
+
24
−
0
View file @
aa2ac201
...
@@ -97,6 +97,12 @@ Swap1* Swap1::from_legacy(string file_name) {
...
@@ -97,6 +97,12 @@ Swap1* Swap1::from_legacy(string file_name) {
return
instance
;
return
instance
;
}
}
long
Swap1
::
get_memory_requirement
(
int
lm
)
{
long
size
=
(
long
)
sizeof
(
int
);
size
+=
(
long
)(
sizeof
(
complex
<
double
>
)
*
2
*
lm
*
(
lm
+
2
));
return
size
;
}
void
Swap1
::
write_binary
(
string
file_name
,
string
mode
)
{
void
Swap1
::
write_binary
(
string
file_name
,
string
mode
)
{
if
(
mode
.
compare
(
"LEGACY"
)
==
0
)
{
if
(
mode
.
compare
(
"LEGACY"
)
==
0
)
{
write_legacy
(
file_name
);
write_legacy
(
file_name
);
...
@@ -302,6 +308,12 @@ Swap2* Swap2::from_legacy(string file_name) {
...
@@ -302,6 +308,12 @@ Swap2* Swap2::from_legacy(string file_name) {
return
instance
;
return
instance
;
}
}
long
Swap2
::
get_memory_requirement
(
int
_nkv
)
{
long
size
=
(
long
)(
3
*
sizeof
(
int
)
+
11
*
sizeof
(
double
));
size
+=
(
long
)(
sizeof
(
double
)
*
_nkv
*
(
_nkv
+
1
));
return
size
;
}
double
Swap2
::
get_param
(
string
param_name
)
{
double
Swap2
::
get_param
(
string
param_name
)
{
double
value
;
double
value
;
if
(
param_name
.
compare
(
"nkv"
)
==
0
)
value
=
1.0
*
nkv
;
if
(
param_name
.
compare
(
"nkv"
)
==
0
)
value
=
1.0
*
nkv
;
...
@@ -711,6 +723,18 @@ std::complex<double> TFRFME::get_matrix_element(int row, int col) {
...
@@ -711,6 +723,18 @@ std::complex<double> TFRFME::get_matrix_element(int row, int col) {
return
wsum
[
row
][
col
];
return
wsum
[
row
][
col
];
}
}
long
TFRFME
::
get_memory_requirement
(
int
_lmode
,
int
_lm
,
int
_nkv
,
int
_nxv
,
int
_nyv
,
int
_nzv
)
{
int
_nlmmt
=
2
*
_lm
*
(
_lm
+
2
);
int
_nrvc
=
_nxv
*
_nyv
*
_nzv
;
long
size
=
(
long
)(
8
*
sizeof
(
int
)
+
8
*
sizeof
(
double
));
size
+=
(
long
)((
_nxv
+
_nyv
+
_nzv
)
*
sizeof
(
double
));
size
+=
(
long
)(
_nlmmt
*
_nrvc
*
sizeof
(
complex
<
double
>
));
return
size
;
}
double
TFRFME
::
get_param
(
string
param_name
)
{
double
TFRFME
::
get_param
(
string
param_name
)
{
double
value
;
double
value
;
if
(
param_name
.
compare
(
"vk"
)
==
0
)
value
=
vk
;
if
(
param_name
.
compare
(
"vk"
)
==
0
)
value
=
vk
;
...
...
This diff is collapsed.
Click to expand it.
src/make.inc
+
2
−
2
View file @
aa2ac201
...
@@ -40,8 +40,8 @@ endif
...
@@ -40,8 +40,8 @@ endif
# CXXFLAGS defines the default compilation options for the C++ compiler
# CXXFLAGS defines the default compilation options for the C++ compiler
ifndef
CXXFLAGS
ifndef
CXXFLAGS
#
override CXXFLAGS=-O
0
-ggdb -pg -coverage -I$(HDF5_INCLUDE)
override
CXXFLAGS
=-
O
3
-
ggdb
-
pg
-
coverage
-
I
$
(
HDF5_INCLUDE
)
override
CXXFLAGS
=-
O3
-
I
$
(
HDF5_INCLUDE
)
#
override CXXFLAGS=-O3 -I$(HDF5_INCLUDE)
endif
endif
# HDF5_LIB defines the default path to the HDF5 libraries to use
# HDF5_LIB defines the default path to the HDF5 libraries to use
...
...
This diff is collapsed.
Click to expand it.
src/trapping/cfrfme.cpp
+
14
−
0
View file @
aa2ac201
...
@@ -225,6 +225,15 @@ void frfme(string data_file, string output_path) {
...
@@ -225,6 +225,15 @@ void frfme(string data_file, string output_path) {
/*vkv = new double[nkv]();
/*vkv = new double[nkv]();
vkzm = new double*[nkv];
vkzm = new double*[nkv];
for (int vi = 0; vi < nkv; vi++) vkzm[vi] = new double[nkv];*/
for (int vi = 0; vi < nkv; vi++) vkzm[vi] = new double[nkv];*/
long
swap1_size
,
swap2_size
,
tfrfme_size
;
double
size_mb
;
printf
(
"INFO: calculation memory requirements
\n
"
);
swap1_size
=
Swap1
::
get_memory_requirement
(
lm
);
size_mb
=
1.0
*
swap1_size
/
1024.0
/
1024.0
;
printf
(
"Swap 1: %.2lg MB
\n
"
,
size_mb
);
swap2_size
=
Swap2
::
get_memory_requirement
(
nkv
);
size_mb
=
1.0
*
swap2_size
/
1024.0
/
1024.0
;
printf
(
"Swap 2: %.2lg MB
\n
"
,
size_mb
);
tt2
=
new
Swap2
(
nkv
);
tt2
=
new
Swap2
(
nkv
);
// End of array initialization
// End of array initialization
double
vkm
=
vk
*
exri
;
double
vkm
=
vk
*
exri
;
...
@@ -243,6 +252,11 @@ void frfme(string data_file, string output_path) {
...
@@ -243,6 +252,11 @@ void frfme(string data_file, string output_path) {
int
nzs
=
nzsh
*
2
;
int
nzs
=
nzsh
*
2
;
int
nzv
=
nzs
+
1
;
int
nzv
=
nzs
+
1
;
int
nzshpo
=
nzsh
+
1
;
int
nzshpo
=
nzsh
+
1
;
tfrfme_size
=
TFRFME
::
get_memory_requirement
(
lmode
,
lm
,
nkv
,
nxv
,
nyv
,
nzv
);
size_mb
=
1.0
*
tfrfme_size
/
1024.0
/
1024.0
;
printf
(
"TFRFME: %.2lg MB
\n
"
,
size_mb
);
size_mb
=
1.0
*
(
swap1_size
+
swap2_size
+
tfrfme_size
)
/
1024.0
/
1024.0
;
printf
(
"TOTAL: %.2lg MB
\n
"
,
size_mb
);
tfrfme
=
new
TFRFME
(
lmode
,
lm
,
nkv
,
nxv
,
nyv
,
nzv
);
tfrfme
=
new
TFRFME
(
lmode
,
lm
,
nkv
,
nxv
,
nyv
,
nzv
);
for
(
int
i24
=
nxshpo
;
i24
<=
nxs
;
i24
++
)
{
for
(
int
i24
=
nxshpo
;
i24
<=
nxs
;
i24
++
)
{
tfrfme
->
set_x
(
i24
,
tfrfme
->
get_x
(
i24
-
1
)
+
delxyz
);
tfrfme
->
set_x
(
i24
,
tfrfme
->
get_x
(
i24
-
1
)
+
delxyz
);
...
...
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