diff --git a/libsharp/sharp.c b/libsharp/sharp.c index b5bb7b1..73d43c0 100644 --- a/libsharp/sharp.c +++ b/libsharp/sharp.c @@ -593,7 +593,8 @@ static void sharp_build_job_common (sharp_job *job, sharp_jobtype type, const sharp_geom_info *geom_info, const sharp_alm_info *alm_info, int ntrans, int dp, int nv) { - UTIL_ASSERT((ntrans>0),"bad number of simultaneous transforms"); + UTIL_ASSERT((ntrans>0)&&(ntrans<=SHARP_MAXTRANS), + "bad number of simultaneous transforms"); if (type==SHARP_ALM2MAP_DERIV1) spin=1; UTIL_ASSERT((spin>=0)&&(spin<=30), "bad spin"); job->type = type; diff --git a/libsharp/sharp_core.c b/libsharp/sharp_core.c index 1d48a6f..4a932a0 100644 --- a/libsharp/sharp_core.c +++ b/libsharp/sharp_core.c @@ -41,6 +41,7 @@ typedef complex double dcmplx; +// must be in the range [0;6] #define MAXJOB_SPECIAL 2 #define XCONCAT2(a,b) a##_##b @@ -81,7 +82,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, { switch (njobs*16+job->nv) { -#if (MAXJOB_SPECIAL>=1) +#if ((MAXJOB_SPECIAL>=1)&&(SHARP_MAXTRANS>=1)) case 0x11: CONCAT3(inner_loop,1,1) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -101,7 +102,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, CONCAT3(inner_loop,6,1) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; #endif -#if (MAXJOB_SPECIAL>=2) +#if ((MAXJOB_SPECIAL>=2)&&(SHARP_MAXTRANS>=2)) case 0x21: CONCAT3(inner_loop,1,2) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -121,7 +122,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, CONCAT3(inner_loop,6,2) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; #endif -#if (MAXJOB_SPECIAL>=3) +#if ((MAXJOB_SPECIAL>=3)&&(SHARP_MAXTRANS>=3)) case 0x31: CONCAT3(inner_loop,1,3) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -141,7 +142,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, CONCAT3(inner_loop,6,3) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; #endif -#if (MAXJOB_SPECIAL>=4) +#if ((MAXJOB_SPECIAL>=4)&&(SHARP_MAXTRANS>=4)) case 0x41: CONCAT3(inner_loop,1,4) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -161,7 +162,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, CONCAT3(inner_loop,6,4) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; #endif -#if (MAXJOB_SPECIAL>=5) +#if ((MAXJOB_SPECIAL>=5)&&(SHARP_MAXTRANS>=5)) case 0x51: CONCAT3(inner_loop,1,5) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -181,7 +182,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, CONCAT3(inner_loop,6,5) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; #endif -#if (MAXJOB_SPECIAL>=6) +#if ((MAXJOB_SPECIAL>=6)&&(SHARP_MAXTRANS>=6)) case 0x61: CONCAT3(inner_loop,1,6) (job, ispair,cth,sth,llim,ulim,gen,mi,idx); return; @@ -203,7 +204,7 @@ void inner_loop (sharp_job *job, const int *ispair,const double *cth, #endif } } -#if (MAXJOB_SPECIAL<6) +#if (SHARP_MAXTRANS>MAXJOB_SPECIAL) else { switch (job->nv) diff --git a/libsharp/sharp_inchelper1.inc.c b/libsharp/sharp_inchelper1.inc.c index 74de2ee..9357fb2 100644 --- a/libsharp/sharp_inchelper1.inc.c +++ b/libsharp/sharp_inchelper1.inc.c @@ -1,11 +1,12 @@ #define Tb CONCAT2(Tb,nvec) #define Y(arg) CONCAT2(arg,nvec) #include "sharp_core_inc.c" -#if (MAXJOB_SPECIAL<6) + +#if (SHARP_MAXTRANS>MAXJOB_SPECIAL) #include "sharp_core_inc3.c" #endif -#if (MAXJOB_SPECIAL>=1) +#if ((MAXJOB_SPECIAL>=1)&&(SHARP_MAXTRANS>=1)) #define njobs 1 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" @@ -13,7 +14,7 @@ #undef njobs #endif -#if (MAXJOB_SPECIAL>=2) +#if ((MAXJOB_SPECIAL>=2)&&(SHARP_MAXTRANS>=2)) #define njobs 2 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" @@ -21,7 +22,7 @@ #undef njobs #endif -#if (MAXJOB_SPECIAL>=3) +#if ((MAXJOB_SPECIAL>=3)&&(SHARP_MAXTRANS>=3)) #define njobs 3 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" @@ -29,7 +30,7 @@ #undef njobs #endif -#if (MAXJOB_SPECIAL>=4) +#if ((MAXJOB_SPECIAL>=4)&&(SHARP_MAXTRANS>=4)) #define njobs 4 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" @@ -37,7 +38,7 @@ #undef njobs #endif -#if (MAXJOB_SPECIAL>=5) +#if ((MAXJOB_SPECIAL>=5)&&(SHARP_MAXTRANS>=5)) #define njobs 5 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" @@ -45,7 +46,7 @@ #undef njobs #endif -#if (MAXJOB_SPECIAL>=6) +#if ((MAXJOB_SPECIAL>=6)&&(SHARP_MAXTRANS>=6)) #define njobs 6 #define Z(arg) CONCAT3(arg,nvec,njobs) #include "sharp_core_inc2.c" diff --git a/libsharp/sharp_internal.h b/libsharp/sharp_internal.h index 1a05256..d573be9 100644 --- a/libsharp/sharp_internal.h +++ b/libsharp/sharp_internal.h @@ -38,6 +38,8 @@ #include "sharp.h" +#define SHARP_MAXTRANS 10 + typedef enum { FLOAT, DOUBLE } sharp_fde; typedef struct