From dca8cc2962e2768a7cb69b5d9717b6e5c78be288 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 19 Feb 2010 22:43:11 +0100 Subject: Move critical array size definitions to share between CPU and GPU versions --- data/Makefile.am | 2 +- data/defs.h | 23 +++++++++++++++++++++++ data/diffraction.cl | 3 +-- src/Makefile.am | 2 ++ src/diffraction-gpu.c | 3 ++- src/diffraction-gpu.h | 21 +++++++++++++++++---- src/utils.h | 6 +----- 7 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 data/defs.h diff --git a/data/Makefile.am b/data/Makefile.am index b55597f0..afecb737 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -2,4 +2,4 @@ hdfseedir = $(datadir)/hdfsee hdfsee_DATA = displaywindow.ui crystfeldir = $(datadir)/crystfel -crystfel_DATA = sfac/* diffraction.cl +crystfel_DATA = sfac/* diffraction.cl defs.h diff --git a/data/defs.h b/data/defs.h new file mode 100644 index 00000000..934d138e --- /dev/null +++ b/data/defs.h @@ -0,0 +1,23 @@ +/* + * defs.h + * + * Constant definitions which must be consistent throughout + * + * (c) 2006-2010 Thomas White + * + * Part of CrystFEL - crystallography with a FEL + * + */ + +#ifndef DEFS_H +#define DEFS_H + + +/* Maxmimum index to hold values up to (can be increased if necessary) */ +#define INDMAX 70 + +/* Array size */ +#define IDIM (INDMAX*2 +1) + + +#endif /* DEFS_H */ diff --git a/data/diffraction.cl b/data/diffraction.cl index 41d331b3..7cb98034 100644 --- a/data/diffraction.cl +++ b/data/diffraction.cl @@ -10,8 +10,7 @@ */ -#define INDMAX 70 -#define IDIM (INDMAX*2 +1) +#include float4 quat_rot(float4 q, float4 z) diff --git a/src/Makefile.am b/src/Makefile.am index 19e8ca41..887271ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,3 +36,5 @@ get_hkl_LDADD = @LIBS@ compare_hkl_SOURCES = compare_hkl.c sfac.c cell.c utils.c reflections.c compare_hkl_LDADD = @LIBS@ + +INCLUDES = "-I$(top_srcdir)/data" diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index 133c0bc1..1d0cb4dd 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -129,7 +129,8 @@ static cl_program load_program(const char *filename, cl_context ctx, return 0; } - r = clBuildProgram(prog, 0, NULL, "-Werror", NULL, NULL); + r = clBuildProgram(prog, 0, NULL, "-Werror -I"DATADIR"/crystfel/", + NULL, NULL); if ( r != CL_SUCCESS ) { ERROR("Couldn't build program '%s'\n", filename); show_build_log(prog, dev); diff --git a/src/diffraction-gpu.h b/src/diffraction-gpu.h index a7446a98..f3bed8bf 100644 --- a/src/diffraction-gpu.h +++ b/src/diffraction-gpu.h @@ -22,19 +22,32 @@ struct gpu_context; #if HAVE_OPENCL + extern void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, int na, int nb, int nc); +extern struct gpu_context *setup_gpu(int no_sfac, struct image *image, + struct molecule *molecule); +extern void cleanup_gpu(struct gpu_context *gctx); + #else + static void get_diffraction_gpu(struct gpu_context *gctx, struct image *image, int na, int nb, int nc) { /* Do nothing */ ERROR("This copy of CrystFEL was not compiled with OpenCL support.\n"); } -#endif -extern struct gpu_context *setup_gpu(int no_sfac, struct image *image, - struct molecule *molecule); -extern void cleanup_gpu(struct gpu_context *gctx); +static struct gpu_context *setup_gpu(int no_sfac, struct image *image, + struct molecule *molecule) +{ + return NULL; +} + +static void cleanup_gpu(struct gpu_context *gctx) +{ +} + +#endif #endif /* DIFFRACTION_GPU_H */ diff --git a/src/utils.h b/src/utils.h index d9d0a0af..d9025fa0 100644 --- a/src/utils.h +++ b/src/utils.h @@ -137,11 +137,7 @@ static inline double angle_between(double x1, double y1, double z1, /* -------------------- Indexed lists for specified types ------------------- */ -/* Maxmimum index to hold values up to (can be increased if necessary) */ -#define INDMAX 70 - -/* Array size */ -#define IDIM (INDMAX*2 +1) +#include "defs.h" #define LIST_SIZE (IDIM*IDIM*IDIM) -- cgit v1.2.3