diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-26 16:29:27 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-27 21:19:36 -0500 |
commit | 03f7a342011a4f69cfcbec7af3e4f1a2e835618b (patch) | |
tree | 8e11d1f162ed3908e007c9bdf1fc1b6952960d83 /sal | |
parent | 6ef6dd0122b8e44d8547ec31f40def42173e4e41 (diff) |
Ensure that numeric array storage is aligned to 256-byte boundary.
OpenCL devices require this else we would get a performance hit.
Change-Id: I6b1db6320fa84f933b6446022a0fd02ba267bf21
Diffstat (limited to 'sal')
-rw-r--r-- | sal/Library_sal.mk | 2 | ||||
-rw-r--r-- | sal/inc/internal/oslmemory.h | 30 | ||||
-rw-r--r-- | sal/osl/unx/memory.c | 26 | ||||
-rw-r--r-- | sal/osl/w32/memory.c | 24 | ||||
-rw-r--r-- | sal/rtl/alloc_global.cxx | 11 | ||||
-rw-r--r-- | sal/util/sal.map | 6 |
6 files changed, 99 insertions, 0 deletions
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk index cbc52a7212bf..6b16426a29ac 100644 --- a/sal/Library_sal.mk +++ b/sal/Library_sal.mk @@ -168,6 +168,7 @@ $(eval $(call gb_Library_add_exception_objects,sal,\ $(if $(filter DESKTOP,$(BUILD_TYPE)), sal/osl/unx/salinit) \ )) $(eval $(call gb_Library_add_cobjects,sal,\ + sal/osl/unx/memory \ sal/osl/unx/mutex \ sal/osl/unx/nlsupport \ sal/osl/unx/pipe \ @@ -253,6 +254,7 @@ $(eval $(call gb_Library_add_cobjects,sal,\ sal/osl/w32/dllentry \ sal/osl/w32/file_error \ sal/osl/w32/interlck \ + sal/osl/w32/memory \ sal/osl/w32/mutex \ sal/osl/w32/nlsupport \ sal/osl/w32/pipe \ diff --git a/sal/inc/internal/oslmemory.h b/sal/inc/internal/oslmemory.h new file mode 100644 index 000000000000..8ef094ad3cad --- /dev/null +++ b/sal/inc/internal/oslmemory.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SAL_INTERNAL_OSLMEMORY_H +#define INCLUDED_SAL_INTERNAL_OSLMEMORY_H + +#include <sal/saldllapi.h> +#include <sal/types.h> + +#if defined __cplusplus +extern "C" { +#endif + +void* osl_aligned_alloc( sal_Size align, sal_Size size ); + +void osl_aligned_free( void* p ); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/memory.c b/sal/osl/unx/memory.c new file mode 100644 index 000000000000..a70bc164f0e5 --- /dev/null +++ b/sal/osl/unx/memory.c @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <internal/oslmemory.h> + +#include <stdlib.h> + +void* osl_aligned_alloc( sal_Size align, sal_Size size ) +{ + void* ptr; + int err = posix_memalign(&ptr, align, size); + return err ? NULL : ptr; +} + +void osl_aligned_free( void* p ) +{ + free(p); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/w32/memory.c b/sal/osl/w32/memory.c new file mode 100644 index 000000000000..279a1681d4e1 --- /dev/null +++ b/sal/osl/w32/memory.c @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <internal/oslmemory.h> + +#include <malloc.h> + +void* osl_aligned_alloc( sal_Size align, sal_Size size ) +{ + return _aligned_malloc(size, align); +} + +void osl_aligned_free( void* p ) +{ + _aligned_free(p); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx index 07cded3eb187..4108333f1fe6 100644 --- a/sal/rtl/alloc_global.cxx +++ b/sal/rtl/alloc_global.cxx @@ -27,6 +27,7 @@ #include <stdio.h> #include "internal/rtllifecycle.h" +#include <internal/oslmemory.h> AllocMode alloc_mode = AMode_UNSET; @@ -378,6 +379,16 @@ void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C() } } +void* SAL_CALL rtl_allocateAlinedMemory (sal_Size Alignment, sal_Size Bytes) SAL_THROW_EXTERN_C() +{ + return osl_aligned_alloc(Alignment, Bytes); +} + +void SAL_CALL rtl_freeAlignedMemory (void* Ptr) SAL_THROW_EXTERN_C() +{ + osl_aligned_free(Ptr); +} + /* ================================================================= */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/util/sal.map b/sal/util/sal.map index 1456d6db1cf8..f63f38b0d0ae 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -670,6 +670,12 @@ LIBO_UDK_4.2 { # symbols available in >= LibO 4.2 rtl_ustr_toUInt32; } LIBO_UDK_4.1; +LIBO_UDK_4.3 { # symbols available in >= LibO 4.3 + global: + rtl_allocateAlinedMemory; + rtl_freeAlignedMemory; +} LIBO_UDK_4.2; + PRIVATE_1.0 { global: osl_detail_ObjectRegistry_storeAddresses; |