summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorplank <plank@36f187d4-5712-4624-889c-152d48957efa>2013-02-08 16:44:30 +0000
committerplank <plank@36f187d4-5712-4624-889c-152d48957efa>2013-02-08 16:44:30 +0000
commitc975077849c8a6c0262e81d2dd24d99e920567ff (patch)
treebc5ea6df094bb61dadceafb90bb65da9d1b74b91
parentac9ec2ab0089155a32ebf6eec1310b44350eb3b4 (diff)
downloadgf-complete-c975077849c8a6c0262e81d2dd24d99e920567ff.tar.gz
Changed the default method for w=4 to use SSE if it is there.
git-svn-id: svn://mamba.eecs.utk.edu/home/plank/svn/Galois-Library@90 36f187d4-5712-4624-889c-152d48957efa
-rw-r--r--gf.c7
-rw-r--r--gf_int.h2
-rw-r--r--gf_w4.c8
3 files changed, 9 insertions, 8 deletions
diff --git a/gf.c b/gf.c
index 195bb2f..769caae 100644
--- a/gf.c
+++ b/gf.c
@@ -104,9 +104,9 @@ void gf_alignment_error(char *s, int a)
exit(1);
}
-/* Lifted this code from Jens Gregor -- thanks, Jens */
+/* Lifted this code from Jens Gregor -- thanks, Jens. Tests for SSE3 */
-int gf_is_sse2()
+int gf_is_sse()
{
unsigned int cpeinfo;
unsigned int cpsse;
@@ -114,7 +114,8 @@ int gf_is_sse2()
"cpuid\n\t"
"mov %%edx, %0\n\t"
"mov %%ecx, %1\n" : "=m" (cpeinfo), "=m" (cpsse));
- if ((cpeinfo >> 26) & 0x1 ) return 1;
+ if ((cpsse ) & 0x1 ) return 1;
+
return 0;
}
diff --git a/gf_int.h b/gf_int.h
index fa962b0..593e4d1 100644
--- a/gf_int.h
+++ b/gf_int.h
@@ -14,7 +14,7 @@ extern void timer_start (double *t);
extern double timer_split (const double *t);
extern void galois_fill_random (void *buf, int len, unsigned int seed);
-extern int galois_is_sse();
+extern int gf_is_sse();
typedef struct {
int mult_type;
diff --git a/gf_w4.c b/gf_w4.c
index 2dced97..ad58fe8 100644
--- a/gf_w4.c
+++ b/gf_w4.c
@@ -385,7 +385,7 @@ int gf_w4_single_table_init(gf_t *gf)
gf->inverse.w32 = NULL;
gf->divide.w32 = gf_w4_single_table_divide;
gf->multiply.w32 = gf_w4_single_table_multiply;
- if (h->region_type & GF_REGION_SSE) {
+ if ((h->region_type & GF_REGION_SSE) || (h->mult_type == GF_MULT_DEFAULT && gf_is_sse())) {
gf->multiply_region.w32 = gf_w4_single_table_sse_multiply_region;
} else {
gf->multiply_region.w32 = gf_w4_single_table_multiply_region;
@@ -1921,12 +1921,13 @@ int gf_w4_scratch_size(int mult_type, int region_type, int divide_type, int arg1
}
return sizeof(gf_internal_t) + sizeof(struct gf_bytwo_data);
break;
+ case GF_MULT_DEFAULT:
case GF_MULT_TABLE:
if (arg1 != 0 || arg2 != 0) return -1;
if (region_type == GF_REGION_CAUCHY || region_type == (GF_REGION_CAUCHY | GF_REGION_SINGLE_TABLE)) {
return sizeof(gf_internal_t) + sizeof(struct gf_single_table_data) + 64;
}
- if (region_type == 0) region_type = GF_REGION_SINGLE_TABLE;
+ if (mult_type == GF_MULT_DEFAULT || region_type == 0) region_type = GF_REGION_SINGLE_TABLE;
if (region_type & GF_REGION_SINGLE_TABLE) {
if ((region_type | sss) != sss) return -1;
if ((region_type & sss) == sss) return -1;
@@ -1944,7 +1945,6 @@ int gf_w4_scratch_size(int mult_type, int region_type, int divide_type, int arg1
}
return -1;
break;
- case GF_MULT_DEFAULT:
case GF_MULT_LOG_TABLE:
if (arg1 != 0 || arg2 != 0 || (region_type != 0 && region_type != GF_REGION_CAUCHY)) return -1;
return sizeof(gf_internal_t) + sizeof(struct gf_logtable_data) + 64;
@@ -1977,8 +1977,8 @@ gf_w4_init (gf_t *gf)
case GF_MULT_BYTWO_p:
case GF_MULT_BYTWO_b:
if (gf_w4_bytwo_init(gf) == 0) return 0; break;
- case GF_MULT_DEFAULT:
case GF_MULT_LOG_TABLE: if (gf_w4_log_init(gf) == 0) return 0; break;
+ case GF_MULT_DEFAULT:
case GF_MULT_TABLE: if (gf_w4_table_init(gf) == 0) return 0; break;
default: return 0;
}