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
argo
Applications
LAMMPS
Commits
fb7b42ec
Commit
fb7b42ec
authored
Sep 30, 2017
by
Richard Berger
Browse files
Add support for aligned allocations on Windows
parent
183980e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/memory.cpp
View file @
fb7b42ec
...
...
@@ -49,6 +49,8 @@ void *Memory::smalloc(bigint nbytes, const char *name)
#if defined(LMP_USE_TBB_ALLOCATOR)
ptr
=
scalable_aligned_malloc
(
nbytes
,
LAMMPS_MEMALIGN
);
#elif defined(_WIN32)
ptr
=
_aligned_malloc
(
nbytes
,
LAMMPS_MEMALIGN
);
#else
int
retval
=
posix_memalign
(
&
ptr
,
LAMMPS_MEMALIGN
,
nbytes
);
if
(
retval
)
ptr
=
NULL
;
...
...
@@ -109,6 +111,8 @@ void Memory::sfree(void *ptr)
if
(
ptr
==
NULL
)
return
;
#if defined(LMP_USE_TBB_ALLOCATOR)
scalable_aligned_free
(
ptr
);
#elif defined(_WIN32)
_aligned_free
(
ptr
);
#else
free
(
ptr
);
#endif
...
...
src/my_page.h
View file @
fb7b42ec
...
...
@@ -220,8 +220,14 @@ class MyPage {
for
(
int
i
=
npage
-
pagedelta
;
i
<
npage
;
i
++
)
{
#if defined(LAMMPS_MEMALIGN)
void
*
ptr
;
#ifdef _WIN32
ptr
=
_aligned_malloc
(
pagesize
*
sizeof
(
T
),
LAMMPS_MEMALIGN
);
if
(
ptr
==
NULL
)
errorflag
=
2
;
#else
if
(
posix_memalign
(
&
ptr
,
LAMMPS_MEMALIGN
,
pagesize
*
sizeof
(
T
)))
errorflag
=
2
;
#endif
pages
[
i
]
=
(
T
*
)
ptr
;
#else
pages
[
i
]
=
(
T
*
)
malloc
(
pagesize
*
sizeof
(
T
));
...
...
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