Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymatlib
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Rahil Doshi
pymatlib
Commits
a80aa59e
Commit
a80aa59e
authored
3 months ago
by
Rahil Doshi
Browse files
Options
Downloads
Patches
Plain Diff
Remove testing code from HeatEquationKernelWithMaterial app
parent
b4f9fef6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/CodegenHeatEquationWithMaterial.cpp
+1
-112
1 addition, 112 deletions
apps/CodegenHeatEquationWithMaterial.cpp
apps/HeatEquationKernelWithMaterial.py
+1
-1
1 addition, 1 deletion
apps/HeatEquationKernelWithMaterial.py
with
2 additions
and
113 deletions
apps/CodegenHeatEquationWithMaterial.cpp
+
1
−
112
View file @
a80aa59e
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include
"timeloop/SweepTimeloop.h"
#include
"timeloop/SweepTimeloop.h"
#include
"gen/HeatEquationKernelWithMaterial.hpp"
#include
"gen/HeatEquationKernelWithMaterial.hpp"
// #include "interpolate_binary_search_cpp.h"
namespace
walberla
namespace
walberla
{
{
...
@@ -165,114 +164,4 @@ int main(int argc, char** argv)
...
@@ -165,114 +164,4 @@ int main(int argc, char** argv)
}
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
walberla
::
main
(
argc
,
argv
);
}
void
test_performance
()
{
// Configuration parameters
constexpr
int
warmupSteps
=
5
;
constexpr
int
outerIterations
=
10
;
constexpr
int
numCells
=
64
*
64
*
64
;
// Setup test data
SS316L
test
;
std
::
vector
<
double
>
random_energies
(
numCells
);
// Generate random values
std
::
random_device
rd
;
std
::
mt19937
gen
(
rd
());
const
double
E_min
=
SS316L
::
E_neq
.
front
()
*
0.8
;
const
double
E_max
=
SS316L
::
E_neq
.
back
()
*
1.2
;
std
::
uniform_real_distribution
<
double
>
dist
(
E_min
,
E_max
);
// Fill random energies
for
(
auto
&
E
:
random_energies
)
{
E
=
dist
(
gen
);
}
// Warmup runs
std
::
cout
<<
"Performing warmup steps..."
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
warmupSteps
;
++
i
)
{
for
(
const
double
&
E
:
random_energies
)
{
// volatile double result = interpolate_double_lookup(E, test);
volatile
double
result
=
test
.
interpolateDL
(
E
);
}
}
for
(
int
i
=
0
;
i
<
warmupSteps
;
++
i
)
{
for
(
const
double
&
E
:
random_energies
)
{
volatile
double
result
=
test
.
interpolateBS
(
E
);
}
}
// Performance measurement
std
::
cout
<<
"
\n
Starting performance measurement..."
<<
std
::
endl
;
std
::
vector
<
double
>
timings_binary
;
std
::
vector
<
double
>
timings_double_lookup
;
for
(
int
iter
=
0
;
iter
<
outerIterations
;
++
iter
)
{
std
::
cout
<<
"
\n
Iteration "
<<
iter
+
1
<<
"/"
<<
outerIterations
<<
std
::
endl
;
// Double Lookup timing
{
const
auto
start1
=
std
::
chrono
::
high_resolution_clock
::
now
();
for
(
const
double
&
E
:
random_energies
)
{
volatile
double
result
=
test
.
interpolateDL
(
E
);
}
const
auto
end1
=
std
::
chrono
::
high_resolution_clock
::
now
();
const
auto
duration1
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
end1
-
start1
).
count
();
timings_double_lookup
.
push_back
(
static_cast
<
double
>
(
duration1
));
std
::
cout
<<
"Double Lookup - Iteration time: "
<<
duration1
<<
" ns"
<<
std
::
endl
;
}
// Binary Search timing
{
const
auto
start2
=
std
::
chrono
::
high_resolution_clock
::
now
();
for
(
const
double
&
E
:
random_energies
)
{
volatile
double
result
=
test
.
interpolateBS
(
E
);
}
const
auto
end2
=
std
::
chrono
::
high_resolution_clock
::
now
();
const
auto
duration2
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
end2
-
start2
).
count
();
timings_binary
.
push_back
(
static_cast
<
double
>
(
duration2
));
std
::
cout
<<
"Binary Search - Iteration time: "
<<
duration2
<<
" ns"
<<
std
::
endl
;
}
}
// Calculate and print statistics
auto
calc_stats
=
[](
const
std
::
vector
<
double
>&
timings
)
{
double
sum
=
std
::
accumulate
(
timings
.
begin
(),
timings
.
end
(),
0.0
);
double
mean
=
sum
/
static_cast
<
double
>
(
timings
.
size
());
double
sq_sum
=
std
::
inner_product
(
timings
.
begin
(),
timings
.
end
(),
timings
.
begin
(),
0.0
);
double
stdev
=
std
::
sqrt
(
sq_sum
/
static_cast
<
double
>
(
timings
.
size
())
-
mean
*
mean
);
return
std
::
make_pair
(
mean
,
stdev
);
};
auto
[
binary_mean
,
binary_stdev
]
=
calc_stats
(
timings_binary
);
auto
[
lookup_mean
,
lookup_stdev
]
=
calc_stats
(
timings_double_lookup
);
std
::
cout
<<
"
\n
Performance Results ("
<<
numCells
<<
" cells, "
<<
outerIterations
<<
" iterations):"
<<
std
::
endl
;
std
::
cout
<<
"Binary Search:"
<<
std
::
endl
;
std
::
cout
<<
" Mean time: "
<<
binary_mean
<<
" ± "
<<
binary_stdev
<<
" ns"
<<
std
::
endl
;
std
::
cout
<<
" Per cell: "
<<
binary_mean
/
numCells
<<
" ns"
<<
std
::
endl
;
std
::
cout
<<
"Double Lookup:"
<<
std
::
endl
;
std
::
cout
<<
" Mean time: "
<<
lookup_mean
<<
" ± "
<<
lookup_stdev
<<
" ns"
<<
std
::
endl
;
std
::
cout
<<
" Per cell: "
<<
lookup_mean
/
numCells
<<
" ns"
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
walberla
::
main
(
argc
,
argv
);
/*constexpr SS316L_1 test_1;
const double result_1 = test_1.interpolateDL(7.88552550e+09);
const double result_2 = test_1.interpolateDL(1.02864255e+10);
std::cout << result_1 << std::endl;
std::cout << result_2 << std::endl;*/
test_performance
();
}
This diff is collapsed.
Click to expand it.
apps/HeatEquationKernelWithMaterial.py
+
1
−
1
View file @
a80aa59e
...
@@ -35,7 +35,7 @@ with SourceFileGenerator() as sfg:
...
@@ -35,7 +35,7 @@ with SourceFileGenerator() as sfg:
from
importlib.resources
import
files
from
importlib.resources
import
files
# Access the YAML file as a package resource
# Access the YAML file as a package resource
yaml_path
=
files
(
'
pymatlib.data.alloys.SS316L
'
).
joinpath
(
'
SS304L.yaml
'
)
yaml_path
=
files
(
'
pymatlib.data.alloys.SS316L
'
).
joinpath
(
'
SS304L.yaml
'
)
mat
=
create_alloy_from_yaml
(
str
(
yaml_path
)
,
u
.
center
())
mat
=
create_alloy_from_yaml
(
yaml_path
,
u
.
center
())
# yaml_path_1 = files('pymatlib.data.alloys.SS316L').joinpath('SS304L_1.yaml')
# yaml_path_1 = files('pymatlib.data.alloys.SS316L').joinpath('SS304L_1.yaml')
# mat1 = create_alloy_from_yaml(str(yaml_path_1), u.center())
# mat1 = create_alloy_from_yaml(str(yaml_path_1), u.center())
...
...
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