Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word2vec.c: Minor tweak to reduce CPU pipeline stalls (3% gain) #36

Open
GoogleCodeExporter opened this issue Apr 21, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

The perf utility reported a bottleneck in this area, where it's waiting for the 
'target' variable to be finalized. By computing the next value of target early, 
overall performance is increased by about 3% on a small (128MB) training file.

add next_target next to target in the variable list.

Then in the two negative sampling blocks:
...
          if (d == 0) {
            target = word;
            label = 1;
            next_random = next_random * (unsigned long long)25214903917 + 11;
            next_target = table[(next_random >> 16) % table_size];
          } else {
            target = next_target;
            if (target == 0) target = next_random % (vocab_size - 1) + 1;
            next_random = next_random * (unsigned long long)25214903917 + 11;
            next_target = table[(next_random >> 16) % table_size];
            if (target == word) continue;
            label = 0;
          }
...

Original issue reported on code.google.com by [email protected] on 22 Jul 2015 at 6:40

@GoogleCodeExporter
Copy link
Author

Potentially disregard, might not be valid.  But there are a ton of pipeline 
stalls in word2vec.

One thing that might have similar effect is to move next_random's value-getting 
after using the value for target.

Original comment by [email protected] on 22 Jul 2015 at 4:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant