word2vec icon indicating copy to clipboard operation
word2vec copied to clipboard

Doesn't include any allocation code for Mac

Open JoeStrout opened this issue 7 years ago • 1 comments

I thought this was the Mac-savvy version of the code... but it's failing right out of the box for me on the first allocation (around line 350 of word2vec.c), because the conditional compilation doesn't include a Mac case:

#ifdef _MSC_VER
  syn0 = _aligned_malloc((long long)vocab_size * layer1_size * sizeof(real), 128);
#elif defined  linux
  a = posix_memalign((void **)&syn0, 128, (long long)vocab_size * layer1_size * sizeof(real));
#endif

Neither _MSC_VER nor linux is defined, so we simply don't allocate anything.

Just wondering if I have missed some obvious solution, or whether I need to add a Mac case (or maybe a generic case, simply using calloc?) to each such block.

JoeStrout avatar Sep 19 '18 00:09 JoeStrout

Actually, as a test, just adding #define linux 1 to the top of the file seems to fix it (i.e., the posix functions seem to apply equally well to the Mac). But I'm still not certain that's the proper solution.

JoeStrout avatar Sep 19 '18 00:09 JoeStrout