[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd configure.in cvd/image.h
From: |
Ethan Eade |
Subject: |
[libcvd-members] libcvd configure.in cvd/image.h |
Date: |
Tue, 28 Nov 2006 15:32:56 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Ethan Eade <ethaneade> 06/11/28 15:32:56
Modified files:
. : configure.in
cvd : image.h
Log message:
Use posix_memalign for allocating aligned image blocks, when available.
The configure script now checks for posix_memalign, and image.h uses it
instead of aligned_mem, if available. This eliminates the locking
problem
on POSIX systems.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure.in?cvsroot=libcvd&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/image.h?cvsroot=libcvd&r1=1.30&r2=1.31
Patches:
Index: configure.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure.in,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- configure.in 24 Oct 2006 13:02:29 -0000 1.74
+++ configure.in 28 Nov 2006 15:32:55 -0000 1.75
@@ -662,6 +662,19 @@
fi
fi
+ AC_MSG_CHECKING(for posix_memalign)
+ a=0
+ AC_COMPILE_IFELSE([#include <stdlib.h>
+ int main(){void* mem;
posix_memalign(&mem,16,100); return 0;}],[a=1])
+ if test $a == 1
+ then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(CVD_HAVE_MEMALIGN, 1)
+ AC_SUBST(have_memalign,yes)
+ else
+ AC_MSG_RESULT(no)
+ AC_SUBST(have_memalign,no)
+ fi
AC_MSG_CHECKING([kernel major number])
kernel_major=[`uname -r | $AWK -F'[.-]' '{print $1}'`]
Index: cvd/image.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/image.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- cvd/image.h 18 Nov 2006 10:12:33 -0000 1.30
+++ cvd/image.h 28 Nov 2006 15:32:55 -0000 1.31
@@ -40,6 +40,7 @@
#include <utility>
#include <iterator>
#include <cvd/internal/aligned_mem.h>
+#include <stdlib.h>
namespace CVD {
@@ -740,7 +741,14 @@
*num_copies = 1;
this->my_size = size;
this->my_stride = size.x;
+#if CVD_HAVE_MEMALIGN
+ void* mem=0;
+ const int alloc_err = posix_memalign(&mem, 16,
this->totalsize()*sizeof(T));
+ assert(alloc_err == 0);
+ this->my_data = new (mem) T[this->totalsize()];
+#else
this->my_data =
Internal::aligned_mem<T,16>::alloc(this->totalsize());
+#endif
}
///Create a filled image of a given size
@@ -797,7 +805,12 @@
{
if(this->my_data && *num_copies && --(*num_copies) == 0)
{
+#if CVD_HAVE_MEMALIGN
+ Internal::placement_delete<T>::free(this->my_data,
this->totalsize());
+ free(this->my_data);
+#else
Internal::aligned_mem<T,16>::release(this->my_data);
+#endif
this->my_data = 0;
delete num_copies;
num_copies = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd configure.in cvd/image.h,
Ethan Eade <=