-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fallback for BMI or BMI2 instructions (#4)
* Add fallback for BMI or BMI2 instructions * BMI fallback option in makefile * Update and rename ci.yml to ci-ubuntu.yml * Create ci-mac
- Loading branch information
Showing
9 changed files
with
93 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: CI-Mac | ||
on: [push] | ||
jobs: | ||
build-and-test: | ||
runs-on: macos-latest | ||
steps: | ||
- name: install compilers etc | ||
run: sudo apt install g++ | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- run: make -j$(nproc) test no-BMI2=1 | ||
- run: make -j$(nproc) release no-BMI2=1 | ||
- run: make -j$(nproc) perft no-BMI2=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI | ||
name: CI-Ubuntu | ||
on: [push] | ||
jobs: | ||
build-and-test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# pragma once | ||
|
||
# ifdef __BMI2__ | ||
|
||
# include <x86intrin.h> | ||
# define PEXT _pext_u64 | ||
# define PDEP _pdep_u64 | ||
|
||
# else | ||
|
||
# include <cstdint> | ||
|
||
constexpr uint64_t PEXT(const uint64_t val, uint64_t mask) { | ||
uint64_t res = 0; | ||
for (uint64_t bb = 1; mask; bb += bb) { | ||
if ( val & mask & -mask ) | ||
res |= bb; | ||
mask &= mask - 1; | ||
} | ||
return res; | ||
} | ||
|
||
constexpr uint64_t PDEP(const uint64_t val, uint64_t mask) { | ||
uint64_t res = 0; | ||
for (uint64_t bb = 1; mask; bb += bb) { | ||
if (val & bb) | ||
res |= mask & -mask; | ||
mask &= mask - 1; | ||
} | ||
return res; | ||
} | ||
|
||
# endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# pragma once | ||
|
||
# ifdef __BMI__ | ||
|
||
# include <x86intrin.h> | ||
# define BLSR __blsr_u64 | ||
|
||
# else | ||
|
||
# include <cstdint> | ||
constexpr uint64_t BLSR(const uint64_t x){ return x & (x-1); } | ||
|
||
# endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters