01: /* ///////////////////////////// P /// L /// A /// S /// M /// A /////////////////////////////// */
02: /* ///                    PLASMA auxiliary routines (version 2.1.0)                          ///
03:  * ///                    Author: Jakub Kurzak                                               ///
04:  * ///                    Release Date: November, 15th 2009                                  ///
05:  * ///                    PLASMA is a software package provided by Univ. of Tennessee,       ///
06:  * ///                    Univ. of California Berkeley and Univ. of Colorado Denver          /// */
07: /* ///////////////////////////////////////////////////////////////////////////////////////////// */
08: #include "common.h"
09: #include "allocate.h"
10: #include "auxiliary.h"
11: 
12: #include <stdlib.h>
13: #include <malloc.h>
14: 
15: /* ///////////////////////////////////////////////////////////////////////////////////////////// */
16: void *plasma_shared_alloc(plasma_context_t *plasma, size_t size, int type)
17: {
18:     void *memptr;
19: 
20:     size *= plasma_element_size(type);
21:     if (size <= 0)
22:         return NULL;
23:   //if (posix_memalign(&memptr, STANDARD_PAGE_SIZE, size) != 0) {
24:     if ((memptr = malloc(size)) == NULL) {
25:         plasma_error("plasma_shared_alloc", "posix_memalign() failed");
26:         return NULL;
27:     }
28:     return memptr;
29: }
30: 
31: /* ///////////////////////////////////////////////////////////////////////////////////////////// */
32: void plasma_shared_free(plasma_context_t *plasma, void *ptr)
33: {
34:     if (ptr == NULL)    // somewhat redundant - free() does the same
35:         return;
36:     free(ptr);
37: }
38: 
39: /* ///////////////////////////////////////////////////////////////////////////////////////////// */
40: void *plasma_private_alloc(plasma_context_t *plasma, size_t size, int type)
41: {
42:     void *memptr;
43: 
44:     size *= plasma_element_size(type);
45:     if (size <= 0)
46:         return NULL;
47:   //if (posix_memalign(&memptr, CACHE_LINE_SIZE, size) != 0) {
48:     if ((memptr = malloc(size)) == NULL) {
49:         plasma_error("plasma_private_alloc", "posix_memalign() failed");
50:         return NULL;
51:     }
52:     return memptr;
53: }
54: 
55: /* ///////////////////////////////////////////////////////////////////////////////////////////// */
56: void plasma_private_free(plasma_context_t *plasma, void *ptr)
57: {
58:     if (ptr == NULL)    // somewhat redundant - free() does the same
59:         return;
60:     free(ptr);
61: }
62: