Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IFOS3D
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
KIT
GPI
AG
Software
IFOS3D
Commits
9c1db07f
Commit
9c1db07f
authored
2 weeks ago
by
Holger Obermaier
Browse files
Options
Downloads
Patches
Plain Diff
Use std::swap to swap values
parent
1d8d9a57
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
Draft: Porting from C to Cpp using Multidimensional Subscript Operator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/exchange_buffer.cpp
+13
-60
13 additions, 60 deletions
src/exchange_buffer.cpp
with
13 additions
and
60 deletions
src/exchange_buffer.cpp
+
13
−
60
View file @
9c1db07f
#include
"float3DTensorT.hpp"
#include
<cstring>
#include
<stddef.h>
#include
<utility>
// swap
// Choose default method to push and pop data to the buffer
// available methods: OPENMP, MEMCPY
...
...
@@ -17,21 +18,9 @@ int buffer_push(
int
i3_start
,
int
i3_end
,
int
buffer_counter
)
{
if
(
i1_end
<
i1_start
)
{
int
swap
=
i1_start
;
i1_start
=
i1_end
;
i1_end
=
swap
;
}
if
(
i2_end
<
i2_start
)
{
int
swap
=
i2_start
;
i2_start
=
i2_end
;
i2_end
=
swap
;
}
if
(
i3_end
<
i3_start
)
{
int
swap
=
i3_start
;
i3_start
=
i3_end
;
i3_end
=
swap
;
}
if
(
i1_end
<
i1_start
)
std
::
swap
(
i1_start
,
i1_end
);
if
(
i2_end
<
i2_start
)
std
::
swap
(
i2_start
,
i2_end
);
if
(
i3_end
<
i3_start
)
std
::
swap
(
i3_start
,
i3_end
);
for
(
int
i1
=
i1_start
;
i1
<=
i1_end
;
i1
++
)
{
for
(
int
i2
=
i2_start
;
i2
<=
i2_end
;
i2
++
)
{
#pragma omp simd
...
...
@@ -50,21 +39,9 @@ int buffer_pop(
int
i3_start
,
int
i3_end
,
int
buffer_counter
)
{
if
(
i1_end
<
i1_start
)
{
int
swap
=
i1_start
;
i1_start
=
i1_end
;
i1_end
=
swap
;
}
if
(
i2_end
<
i2_start
)
{
int
swap
=
i2_start
;
i2_start
=
i2_end
;
i2_end
=
swap
;
}
if
(
i3_end
<
i3_start
)
{
int
swap
=
i3_start
;
i3_start
=
i3_end
;
i3_end
=
swap
;
}
if
(
i1_end
<
i1_start
)
std
::
swap
(
i1_start
,
i1_end
);
if
(
i2_end
<
i2_start
)
std
::
swap
(
i2_start
,
i2_end
);
if
(
i3_end
<
i3_start
)
std
::
swap
(
i3_start
,
i3_end
);
for
(
int
i1
=
i1_start
;
i1
<=
i1_end
;
i1
++
)
{
for
(
int
i2
=
i2_start
;
i2
<=
i2_end
;
i2
++
)
{
#pragma omp simd
...
...
@@ -85,21 +62,9 @@ int buffer_push(
int
i3_start
,
int
i3_end
,
int
buffer_counter
)
{
if
(
i1_end
<
i1_start
)
{
int
swap
=
i1_start
;
i1_start
=
i1_end
;
i1_end
=
swap
;
}
if
(
i2_end
<
i2_start
)
{
int
swap
=
i2_start
;
i2_start
=
i2_end
;
i2_end
=
swap
;
}
if
(
i3_end
<
i3_start
)
{
int
swap
=
i3_start
;
i3_start
=
i3_end
;
i3_end
=
swap
;
}
if
(
i1_end
<
i1_start
)
std
::
swap
(
i1_start
,
i1_end
);
if
(
i2_end
<
i2_start
)
std
::
swap
(
i2_start
,
i2_end
);
if
(
i3_end
<
i3_start
)
std
::
swap
(
i3_start
,
i3_end
);
const
size_t
vec_len
=
i3_end
-
i3_start
+
1
;
for
(
int
i1
=
i1_start
;
i1
<=
i1_end
;
i1
++
)
{
for
(
int
i2
=
i2_start
;
i2
<=
i2_end
;
i2
++
)
{
...
...
@@ -117,21 +82,9 @@ int buffer_pop(
int
i3_start
,
int
i3_end
,
int
buffer_counter
)
{
if
(
i1_end
<
i1_start
)
{
int
swap
=
i1_start
;
i1_start
=
i1_end
;
i1_end
=
swap
;
}
if
(
i2_end
<
i2_start
)
{
int
swap
=
i2_start
;
i2_start
=
i2_end
;
i2_end
=
swap
;
}
if
(
i3_end
<
i3_start
)
{
int
swap
=
i3_start
;
i3_start
=
i3_end
;
i3_end
=
swap
;
}
if
(
i1_end
<
i1_start
)
std
::
swap
(
i1_start
,
i1_end
);
if
(
i2_end
<
i2_start
)
std
::
swap
(
i2_start
,
i2_end
);
if
(
i3_end
<
i3_start
)
std
::
swap
(
i3_start
,
i3_end
);
const
size_t
vec_len
=
i3_end
-
i3_start
+
1
;
for
(
int
i1
=
i1_start
;
i1
<=
i1_end
;
i1
++
)
{
for
(
int
i2
=
i2_start
;
i2
<=
i2_end
;
i2
++
)
{
...
...
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