Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
ac275de9
Commit
ac275de9
authored
10 years ago
by
Chichi Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
field_descriptors should be dynamically allocated
parent
c7648627
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
src/field_descriptor.cpp
+2
-4
2 additions, 4 deletions
src/field_descriptor.cpp
src/field_descriptor.hpp
+2
-4
2 additions, 4 deletions
src/field_descriptor.hpp
src/transp.cpp
+13
-12
13 additions, 12 deletions
src/transp.cpp
with
17 additions
and
20 deletions
src/field_descriptor.cpp
+
2
−
4
View file @
ac275de9
#include
"field_descriptor.hpp"
int
field_descriptor
::
initialize
(
field_descriptor
::
field_descriptor
(
int
ndims
,
int
*
n
,
MPI_Datatype
element_type
)
...
...
@@ -33,16 +33,14 @@ int field_descriptor::initialize(
this
->
mpi_dtype
,
&
this
->
mpi_array_dtype
);
MPI_Type_commit
(
&
this
->
mpi_array_dtype
);
return
EXIT_SUCCESS
;
}
int
field_descriptor
::
fi
nalize
()
field_descriptor
::
~
fi
eld_descriptor
()
{
free
((
void
*
)
this
->
sizes
);
free
((
void
*
)
this
->
subsizes
);
free
((
void
*
)
this
->
starts
);
MPI_Type_free
(
&
this
->
mpi_array_dtype
);
return
EXIT_SUCCESS
;
}
int
field_descriptor
::
read
(
...
...
This diff is collapsed.
Click to expand it.
src/field_descriptor.hpp
+
2
−
4
View file @
ac275de9
...
...
@@ -20,13 +20,11 @@ class field_descriptor
int
local_size
,
full_size
;
MPI_Datatype
mpi_array_dtype
,
mpi_dtype
;
field_descriptor
(){}
~
field_descriptor
(){}
int
initialize
(
field_descriptor
(
int
ndims
,
int
*
n
,
MPI_Datatype
element_type
);
int
finalize
();
~
field_descriptor
();
int
read
(
const
char
*
fname
,
void
*
buffer
);
...
...
This diff is collapsed.
Click to expand it.
src/transp.cpp
+
13
−
12
View file @
ac275de9
...
...
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
nprocs
);
int
n
[
3
];
field_descriptor
f0
,
f1
;
field_descriptor
*
f0
,
*
f1
;
switch
(
argc
)
{
...
...
@@ -19,10 +19,10 @@ int main(int argc, char *argv[])
// dimensions
n
[
0
]
=
atoi
(
argv
[
1
]);
n
[
1
]
=
atoi
(
argv
[
2
]);
f0
.
initialize
(
2
,
n
,
MPI_FLOAT
);
f0
=
new
field_descriptor
(
2
,
n
,
MPI_FLOAT
);
n
[
0
]
=
atoi
(
argv
[
2
]);
n
[
1
]
=
atoi
(
argv
[
1
]);
f1
.
initialize
(
2
,
n
,
MPI_FLOAT
);
f1
=
new
field_descriptor
(
2
,
n
,
MPI_FLOAT
);
break
;
case
4
:
if
(
myrank
==
0
)
...
...
@@ -31,29 +31,30 @@ int main(int argc, char *argv[])
n
[
0
]
=
atoi
(
argv
[
1
]);
n
[
1
]
=
atoi
(
argv
[
2
]);
n
[
2
]
=
atoi
(
argv
[
3
]);
f0
.
initialize
(
3
,
n
,
MPI_FLOAT
);
f0
=
new
field_descriptor
(
3
,
n
,
MPI_FLOAT
);
n
[
0
]
=
atoi
(
argv
[
3
]);
n
[
1
]
=
atoi
(
argv
[
2
]);
n
[
2
]
=
atoi
(
argv
[
1
]);
f1
.
initialize
(
3
,
n
,
MPI_FLOAT
);
f1
=
new
field_descriptor
(
3
,
n
,
MPI_FLOAT
);
break
;
default:
printf
(
"you messed up the parameters, I'm not doing anything.
\n
"
);
f0
.
finalize
();
f1
.
finalize
();
MPI_Finalize
();
return
EXIT_SUCCESS
;
break
;
}
float
*
a0
,
*
a1
;
a0
=
(
float
*
)
malloc
(
f0
.
local_size
*
sizeof
(
float
));
a1
=
(
float
*
)
malloc
(
f1
.
local_size
*
sizeof
(
float
));
f0
.
read
(
"data0"
,
(
void
*
)
a0
);
f0
.
transpose
(
a0
,
a1
);
f1
.
write
(
"data1"
,
(
void
*
)
a1
);
a0
=
(
float
*
)
malloc
(
f0
->
local_size
*
sizeof
(
float
));
a1
=
(
float
*
)
malloc
(
f1
->
local_size
*
sizeof
(
float
));
f0
->
read
(
"data0"
,
(
void
*
)
a0
);
f0
->
transpose
(
a0
,
a1
);
f1
->
write
(
"data1"
,
(
void
*
)
a1
);
free
(
a0
);
free
(
a1
);
delete
f0
;
delete
f1
;
MPI_Finalize
();
return
EXIT_SUCCESS
;
}
...
...
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