Selaa lähdekoodia

some systems don't have memalign

Cédric Augonnet 16 vuotta sitten
vanhempi
commit
407c0fa3dc
3 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 5 0
      configure.ac
  2. 8 0
      examples/ppm-downscaler/ppm-downscaler.c
  3. 2 0
      include/starpu_config.h.in

+ 5 - 0
configure.ac

@@ -72,6 +72,11 @@ if test x$have_malloc_h_header = xyes; then
 	AC_DEFINE(HAVE_MALLOC_H_HEADER,[],[malloc.h header is available])
 fi
 
+AC_CHECK_FUNC(memalign, have_memalign=yes, have_memalign=no)
+if test x$have_memalign = xyes; then
+	AC_DEFINE(HAVE_MEMALIGN,[],[memalign is available])
+fi
+
 # This defines HAVE_SYNC_BUILTINS
 STARPU_CHECK_SYNC_BUILTINS
 

+ 8 - 0
examples/ppm-downscaler/ppm-downscaler.c

@@ -34,7 +34,11 @@ struct ppm_image *allocate_new_ppm(int ncols, int nlines, int coldepth)
 	ppm->nlines = nlines;
 	ppm->coldepth = coldepth;
 
+#ifdef HAVE_MEMALIGN
 	ppm->data = memalign(16384, ncols*nlines*sizeof(struct ppm_color));
+#else
+	ppm->data = malloc(ncols*nlines*sizeof(struct ppm_color));
+#endif
 	assert(ppm->data);
 
 	return ppm;
@@ -58,7 +62,11 @@ struct ppm_image *file_to_ppm(char *filename)
 	}
 	
 	/* allocate a buffer for the image */
+#ifdef HAVE_MEMALIGN
 	ppm->data = memalign(16384, ppm->ncols*ppm->nlines*sizeof(struct ppm_color));
+#else
+	ppm->data = malloc(ppm->ncols*ppm->nlines*sizeof(struct ppm_color));
+#endif
 	assert(ppm->data);
 
 	fread(ppm->data, sizeof(struct ppm_color), ppm->ncols*ppm->nlines, file);

+ 2 - 0
include/starpu_config.h.in

@@ -19,6 +19,8 @@
 
 #undef HAVE_POSIX_MEMALIGN
 
+#undef HAVE_MEMALIGN
+
 #undef HAVE_MALLOC_H_HEADER
 
 #undef HAVE_SYNC_BUILTINS