OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-CompactHash commits / e5fce0b

More changes merged
e5fce0b46376fd5e7cf3bc5441d3f9121ba32326
by brobey <brobey@lanl.gov> · 2015-10-21T20:35:10.000Z

Changed files (1) +40 -29

simplehash/simplehash.c +40 -29
……@@ -33,7 +33,6 @@
3333#include <stdio.h>
3434#include <stdlib.h>
3535#include "simplehash.h"
36//#include "timer/timer.h"
3736
3837static ulong AA;
3938static ulong BB;
……@@ -1108,6 +1107,34 @@ int read_hash_primejump_report_level_3(ulong hashkey, int *hash){
11081107void compact_hash_delete(int *hash){
11091108 free(hash);
11101109}
1110
1111void write_hash_collision_report(void){
1112 if (hash_method == PERFECT_HASH) return;
1113 if (hash_report_level == 1) {
1114 write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells;
1115 write_hash_collisions_count++;
1116 } else if (hash_report_level >= 2) {
1117 printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells);
1118 }
1119}
1120
1121void read_hash_collision_report(void){
1122 if (hash_method == PERFECT_HASH) return;
1123 if (hash_report_level == 1) {
1124 read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries;
1125 read_hash_collisions_count++;
1126 } else if (hash_report_level >= 2) {
1127 printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries);
1128 hash_queries = 0;
1129 read_hash_collisions = 0;
1130 }
1131}
1132
1133void final_hash_collision_report(void){
1134 if (hash_report_level >= 1 && read_hash_collisions_count > 0) {
1135 printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count);
1136 }
1137}
11111138int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulong hashkey, int *hash){
11121139 //int hash_report_level = 3;
11131140 int max_collisions_allowed = 1000;
……@@ -1153,6 +1180,9 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon
11531180 }
11541181 }
11551182 read_hash_collisions += icount;
1183 } else {
1184 printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level);
1185 exit(1);
11561186 }
11571187 } else if (hash_method == QUADRATIC) {
11581188 if (hash_report_level == 0) {
……@@ -1190,6 +1220,9 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon
11901220 }
11911221 }
11921222 read_hash_collisions += icount;
1223 } else {
1224 printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level);
1225 exit(1);
11931226 }
11941227 } else if (hash_method == PRIME_JUMP) {
11951228 uint jump = 1+hashkey%hash_jump_prime;
……@@ -1228,38 +1261,16 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon
12281261 }
12291262 }
12301263 read_hash_collisions += icount;
1264 } else {
1265 printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level);
1266 exit(1);
12311267 }
1268 } else {
1269 printf("Error -- Illegal value of hash_method %d\n",hash_method);
1270 exit(1);
12321271 }
12331272
12341273 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
12351274 return(hashval);
12361275}
12371276
1238void write_hash_collision_report(void){
1239 if (! do_compact_hash) return;
1240 if (hash_report_level == 1) {
1241 write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells;
1242 write_hash_collisions_count++;
1243 } else if (hash_report_level >= 2) {
1244 printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells);
1245 }
1246}
1247
1248void read_hash_collision_report(void){
1249 if (! do_compact_hash) return;
1250 if (hash_report_level == 1) {
1251 read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries;
1252 read_hash_collisions_count++;
1253 } else if (hash_report_level >= 2) {
1254 printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries);
1255 hash_queries = 0;
1256 read_hash_collisions = 0;
1257 }
1258}
1259
1260void final_hash_collision_report(void){
1261 if (hash_report_level >= 1 && read_hash_collisions_count > 0) {
1262 printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count);
1263 }
1264}
1265