w2v-server: use different data structures for i->h connections and hidden nodes
diff --git a/w2v-server.pl b/w2v-server.pl
index 5a24fdb..dc115a3 100644
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -104,7 +104,7 @@
unsigned long upto;
} knnpars;
-float *M, *syn1neg_window, *expTable;
+float *M, *M2, *syn1neg_window, *expTable;
char *vocab;
long long words, size;
@@ -181,14 +181,14 @@
if( (net_fd = open(net_name, O_RDONLY)) >= 0) {
window = (lseek(net_fd, 0, SEEK_END) - sizeof(float) * words * size) / words / size / sizeof(float) / 2;
// lseek(net_fd, sizeof(float) * words * size, SEEK_SET);
- munmap(M, sizeof(float) * words * size);
- M = mmap(0, sizeof(float) * words * size + sizeof(float) * 2 * window * size * words, PROT_READ, MAP_SHARED, net_fd, 0);
+ // munmap(M, sizeof(float) * words * size);
+ M2 = mmap(0, sizeof(float) * words * size + sizeof(float) * 2 * window * size * words, PROT_READ, MAP_SHARED, net_fd, 0);
if (M == MAP_FAILED) {
close(net_fd);
fprintf(stderr, "Cannot mmap %s\n", net_name);
exit(-1);
}
- syn1neg_window = M + words * size;
+ syn1neg_window = M2 + words * size;
} else {
fprintf(stderr, "Cannot open %s\n", net_name);
exit(-1);
@@ -252,7 +252,7 @@
continue;
f = 0;
for (c = 0; c < size; c++)
- f += M[d* size + c] * syn1neg_window[target * window_layer_size + window_offset + c];
+ f += M2[d* size + c] * syn1neg_window[target * window_layer_size + window_offset + c];
if (f < -MAX_EXP)
continue;
else if (f > MAX_EXP)