Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,37 @@ jobs:
with:
files: |
./wheelhouse/**
build_windows:
name: Build wheels on windows-latest ${{ matrix.python }}
runs-on: windows-latest
strategy:
matrix:
python: [ cp38-*, cp39-*, cp310-*, cp311-*, cp312-*, cp313-* ]
steps:
- uses: actions/checkout@v4
# Used to host cibuildwheel
- uses: actions/setup-python@v4
with:
python-version: |
3.11
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.21.3
- name: Build wheels
env:
CIBW_BUILD: ${{ matrix.python }}
CIBW_BEFORE_BUILD: python -m pip install pip Cython ninja --upgrade
CIBW_ARCHS_WINDOWS: AMD64
CIBW_SKIP: pp*
run: python -m cibuildwheel --output-dir wheelhouse
- name: Install dependencies
run: python -m pip install setuptools wheel twine
- name: Publish to PyPI
run: twine upload -u __token__ -p ${{ secrets.PYPI_ACCESS_TOKEN }} ./wheelhouse/*
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./wheelhouse/**
build_mac:
name: Build wheels on macos-14
runs-on: macos-14
Expand Down
42 changes: 26 additions & 16 deletions _custom_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,39 @@ def build_cmake(self, ext):

config = 'Debug' if self.debug else 'Release'
num_cpus = 4
try:
num_cpus = multiprocessing.cpu_count()
except NotImplementedError:
pass

if os.name == "posix":
try:
num_cpus = multiprocessing.cpu_count()
except NotImplementedError:
pass
CMAKE_GENERATOR = "Unix Makefiles"
cmake_args = [
'-G', CMAKE_GENERATOR,
f'-DCMAKE_BUILD_TYPE={config}',
str(Path(ext.name).absolute()) # src directory path
]
build_args = [
'--config', config,
'--', f'-j{num_cpus}'
]
elif os.name == "nt":
CMAKE_GENERATOR = "MinGW Makefiles"
# On Windows, use Ninja or Visual Studio generator
# Ninja is preferred for better compatibility with cibuildwheel
CMAKE_GENERATOR = "Ninja"
cmake_args = [
'-G', CMAKE_GENERATOR,
f'-DCMAKE_BUILD_TYPE={config}',
str(Path(ext.name).absolute()) # src directory path
]
build_args = [
'--config', config,
'--parallel', str(num_cpus)
]
else:
print("Unsupported OS: " + os.name)
sys.exit(1)

cmake_args = [
'-G', CMAKE_GENERATOR,
f'-DCMAKE_BUILD_TYPE={config}',
Path(ext.name).absolute() # src directory path
]

build_args = [
'--config', config,
'--', f'-j{num_cpus}'
]

os.chdir(str(build_temp))
self.spawn(['cmake', str(cwd)] + cmake_args)
if not self.dry_run:
Expand Down
46 changes: 46 additions & 0 deletions src/search/bliss/timer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <sys/times.h>
#endif
#include "timer.h"

/*
Expand All @@ -24,6 +28,47 @@

namespace bliss {

#ifdef _WIN32
// Windows implementation using GetProcessTimes
Timer::Timer()
{
reset();
}

void Timer::reset()
{
FILETIME creationTime, exitTime, kernelTime, userTime;
if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) {
ULARGE_INTEGER kt, ut;
kt.LowPart = kernelTime.dwLowDateTime;
kt.HighPart = kernelTime.dwHighDateTime;
ut.LowPart = userTime.dwLowDateTime;
ut.HighPart = userTime.dwHighDateTime;
// Convert 100-nanosecond intervals to seconds
start_time = (double)(kt.QuadPart + ut.QuadPart) / 10000000.0;
} else {
start_time = 0.0;
}
}

double Timer::get_duration()
{
FILETIME creationTime, exitTime, kernelTime, userTime;
if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) {
ULARGE_INTEGER kt, ut;
kt.LowPart = kernelTime.dwLowDateTime;
kt.HighPart = kernelTime.dwHighDateTime;
ut.LowPart = userTime.dwLowDateTime;
ut.HighPart = userTime.dwHighDateTime;
// Convert 100-nanosecond intervals to seconds
double current_time = (double)(kt.QuadPart + ut.QuadPart) / 10000000.0;
return current_time - start_time;
}
return 0.0;
}

#else
// Unix/Linux implementation using times()
static const double numTicksPerSec = (double)(sysconf(_SC_CLK_TCK));

Timer::Timer()
Expand Down Expand Up @@ -52,5 +97,6 @@ double Timer::get_duration()
numTicksPerSec;
return intermediate - start_time;
}
#endif

} // namespace bliss
Loading