Skip to content

Commit

Permalink
Some fixes for building on windows + cuda (#1614)
Browse files Browse the repository at this point in the history
Summary:
Upstreaming some work towards #1586 from conda-forge/faiss-split-feedstock#19; complements #1610

Pull Request resolved: #1614

Reviewed By: mdouze

Differential Revision: D25864994

Pulled By: wickedfoo

fbshipit-source-id: 4abaaebf1c4102c24c3a9dca544744318e780581
  • Loading branch information
h-vetinari authored and facebook-github-bot committed Jan 11, 2021
1 parent 1c996d0 commit 3d3d539
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion faiss/gpu/impl/PQCodeLoad.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ inline __device__ unsigned int getByte(unsigned int v,
return getBitfield(v, pos, width);
}

inline __device__ unsigned int getByte(unsigned long v,
inline __device__ unsigned int getByte(uint64_t v,
int pos,
int width) {
return getBitfield(v, pos, width);
Expand Down
4 changes: 2 additions & 2 deletions faiss/gpu/utils/PtxUtils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ unsigned int getBitfield(unsigned int val, int pos, int len) {
}

__device__ __forceinline__
unsigned long getBitfield(unsigned long val, int pos, int len) {
unsigned long ret;
uint64_t getBitfield(uint64_t val, int pos, int len) {
uint64_t ret;
asm("bfe.u64 %0, %1, %2, %3;" : "=l"(ret) : "l"(val), "r"(pos), "r"(len));
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions faiss/gpu/utils/StackDeviceMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <faiss/gpu/utils/DeviceUtils.h>
#include <faiss/gpu/utils/StaticUtils.h>
#include <faiss/impl/FaissAssert.h>
#include <algorithm>
#include <sstream>

namespace faiss { namespace gpu {
Expand Down
2 changes: 1 addition & 1 deletion faiss/gpu/utils/Tensor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ bool canUseIndexType() {

template <typename IndexType, typename T, typename... U>
bool canUseIndexType(const T& arg, const U&... args) {
return arg.template canUseIndexType() &&
return arg.template canUseIndexType<IndexType>() &&
canUseIndexType(args...);
}

Expand Down
11 changes: 5 additions & 6 deletions faiss/gpu/utils/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <faiss/gpu/utils/Timer.h>
#include <faiss/gpu/utils/DeviceUtils.h>
#include <faiss/impl/FaissAssert.h>
#include <chrono>

namespace faiss { namespace gpu {

Expand Down Expand Up @@ -43,18 +44,16 @@ KernelTimer::elapsedMilliseconds() {
}

CpuTimer::CpuTimer() {
clock_gettime(CLOCK_REALTIME, &start_);
start_ = std::chrono::steady_clock::now();
}

float
CpuTimer::elapsedMilliseconds() {
struct timespec end;
clock_gettime(CLOCK_REALTIME, &end);
auto end = std::chrono::steady_clock::now();

auto diffS = end.tv_sec - start_.tv_sec;
auto diffNs = end.tv_nsec - start_.tv_nsec;
std::chrono::duration<float, std::milli> duration = end - start_;

return 1000.0f * (float) diffS + ((float) diffNs) / 1000000.0f;
return duration.count();
}

} } // namespace
4 changes: 2 additions & 2 deletions faiss/gpu/utils/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include <cuda_runtime.h>
#include <time.h>
#include <chrono>

namespace faiss { namespace gpu {

Expand Down Expand Up @@ -46,7 +46,7 @@ class CpuTimer {
float elapsedMilliseconds();

private:
struct timespec start_;
std::chrono::time_point<std::chrono::steady_clock> start_;
};

} } // namespace

0 comments on commit 3d3d539

Please sign in to comment.