Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
545ed5e9
Commit
545ed5e9
authored
Sep 25, 2018
by
Uwe Schulzweida
Browse files
transpose2dArrayDP: Replaced variable length arrays.
parent
ed7b2a52
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cdf_read.c
View file @
545ed5e9
...
...
@@ -290,18 +290,12 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double *data)
{
const
size_t
cacheBlockSize
=
256
;
// Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
// which should be a decent compromise on many architectures.
#ifdef __cplusplus
double
**
out
=
(
double
**
)
malloc
(
inWidth
*
sizeof
(
double
*
));
double
**
temp
=
(
double
**
)
malloc
(
inHeight
*
sizeof
(
double
*
));
temp
[
0
]
=
(
double
*
)
malloc
(
inHeight
*
inWidth
*
sizeof
(
double
));
memcpy
(
temp
[
0
],
data
,
inHeight
*
inWidth
*
sizeof
(
double
));
for
(
size_t
i
=
0
;
i
<
inWidth
;
i
++
)
out
[
i
]
=
data
+
(
inHeight
*
i
);
for
(
size_t
i
=
1
;
i
<
inHeight
;
i
++
)
temp
[
i
]
=
temp
[
0
]
+
(
inWidth
*
i
);
#else
double
(
*
out
)[
inHeight
]
=
(
double
(
*
)[
inHeight
])
data
;
double
(
*
temp
)[
inWidth
]
=
(
double
(
*
)[
inWidth
])
Malloc
(
inHeight
*
sizeof
(
*
temp
));
memcpy
(
temp
,
data
,
inHeight
*
sizeof
(
*
temp
));
#endif
/*
for ( size_t y = 0; y < inHeight; ++y )
...
...
@@ -317,10 +311,8 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double *data)
out
[
x
][
y
]
=
temp
[
y
][
x
];
}
#ifdef __cplusplus
free
(
out
);
free
(
temp
[
0
]);
#endif
free
(
temp
);
}
...
...
@@ -329,19 +321,12 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float *data)
{
const
size_t
cacheBlockSize
=
256
;
// Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
// which should be a decent compromise on many architectures.
#ifdef __cplusplus
float
**
out
=
(
float
**
)
malloc
(
inWidth
*
sizeof
(
float
*
));
float
**
temp
=
(
float
**
)
malloc
(
inHeight
*
sizeof
(
float
*
));
temp
[
0
]
=
(
float
*
)
malloc
(
inHeight
*
inWidth
*
sizeof
(
float
));
memcpy
(
temp
[
0
],
data
,
inHeight
*
inWidth
*
sizeof
(
float
));
for
(
size_t
i
=
0
;
i
<
inWidth
;
i
++
)
out
[
i
]
=
data
+
(
inHeight
*
i
);
for
(
size_t
i
=
1
;
i
<
inHeight
;
i
++
)
temp
[
i
]
=
temp
[
0
]
+
(
inWidth
*
i
);
#else
float
(
*
out
)[
inHeight
]
=
(
float
(
*
)[
inHeight
])
data
;
float
(
*
temp
)[
inWidth
]
=
(
float
(
*
)[
inWidth
])
Malloc
(
inHeight
*
sizeof
(
*
temp
));
memcpy
(
temp
,
data
,
inHeight
*
sizeof
(
*
temp
));
#endif
/*
for ( size_t y = 0; y < inHeight; ++y )
...
...
@@ -357,10 +342,8 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float *data)
out
[
x
][
y
]
=
temp
[
y
][
x
];
}
#ifdef __cplusplus
free
(
out
);
free
(
temp
[
0
]);
#endif
free
(
temp
);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment