Skip to content

Commit

Permalink
Running format action on source code. Settling on Google styling. Set…
Browse files Browse the repository at this point in the history
…tled on '.clang-format' instead of '_clang-format'. Fixed instructions such that only clang-format 12 is installed (13 changes SortIncludes options from true/false to a trinary set of options, none of which include the word 'false')
  • Loading branch information
daxpryce committed Mar 16, 2023
1 parent e056ad0 commit e0281be
Show file tree
Hide file tree
Showing 96 changed files with 11,618 additions and 11,918 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BasedOnStyle: Google
---
Language: Cpp
...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See [guidelines](CONTRIBUTING.md) for contributing to this project.
Install the following packages through apt-get

```bash
sudo apt install make cmake g++ libaio-dev libgoogle-perftools-dev clang-format libboost-all-dev
sudo apt install make cmake g++ libaio-dev libgoogle-perftools-dev clang-format-12 libboost-all-dev
```

### Install Intel MKL
Expand Down
4 changes: 0 additions & 4 deletions _clang-format

This file was deleted.

24 changes: 13 additions & 11 deletions include/aligned_file_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#define MAX_IO_DEPTH 128

#include <vector>
#include <atomic>
#include <vector>

#ifndef _WINDOWS
#include <fcntl.h>
Expand All @@ -19,13 +19,14 @@ typedef io_context_t IOContext;

#ifndef USE_BING_INFRA
struct IOContext {
HANDLE fhandle = NULL;
HANDLE iocp = NULL;
HANDLE fhandle = NULL;
HANDLE iocp = NULL;
std::vector<OVERLAPPED> reqs;
};
#else
#include "IDiskPriorityIO.h"
#include <atomic>

#include "IDiskPriorityIO.h"
// TODO: Caller code is very callous about copying IOContext objects
// all over the place. MUST verify that it won't cause leaks/logical
// errors.
Expand All @@ -34,9 +35,9 @@ struct IOContext {
struct IOContext {
enum Status { READ_WAIT = 0, READ_SUCCESS, READ_FAILED, PROCESS_COMPLETE };

std::shared_ptr<ANNIndex::IDiskPriorityIO> m_pDiskIO = nullptr;
std::shared_ptr<std::vector<ANNIndex::AsyncReadRequest>> m_pRequests;
std::shared_ptr<std::vector<Status>> m_pRequestsStatus;
std::shared_ptr<ANNIndex::IDiskPriorityIO> m_pDiskIO = nullptr;
std::shared_ptr<std::vector<ANNIndex::AsyncReadRequest> > m_pRequests;
std::shared_ptr<std::vector<Status> > m_pRequestsStatus;

// waitonaddress on this memory to wait for IO completion signal
// reader should signal this memory after IO completion
Expand All @@ -56,20 +57,21 @@ struct IOContext {
#endif

#include <malloc.h>

#include <cstdio>
#include <mutex>
#include <thread>

#include "tsl/robin_map.h"
#include "utils.h"

// NOTE :: all 3 fields must be 512-aligned
struct AlignedRead {
uint64_t offset; // where to read from
uint64_t len; // how much to read
void* buf; // where to read into
void* buf; // where to read into

AlignedRead() : offset(0), len(0), buf(nullptr) {
}
AlignedRead() : offset(0), len(0), buf(nullptr) {}

AlignedRead(uint64_t offset, uint64_t len, void* buf)
: offset(offset), len(len), buf(buf) {
Expand All @@ -83,7 +85,7 @@ struct AlignedRead {
class AlignedFileReader {
protected:
tsl::robin_map<std::thread::id, IOContext> ctx_map;
std::mutex ctx_mut;
std::mutex ctx_mut;

public:
// returns the thread-specific context
Expand Down
39 changes: 20 additions & 19 deletions include/ann_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the MIT license.

#pragma once
#include <string>
#include <stdexcept>
#include <string>
#include <system_error>

#include "windows_customizations.h"

#ifndef _WINDOWS
Expand All @@ -13,24 +14,24 @@

namespace diskann {

class ANNException : public std::runtime_error {
public:
DISKANN_DLLEXPORT ANNException(const std::string& message, int errorCode);
DISKANN_DLLEXPORT ANNException(const std::string& message, int errorCode,
const std::string& funcSig,
const std::string& fileName,
unsigned int lineNum);
class ANNException : public std::runtime_error {
public:
DISKANN_DLLEXPORT ANNException(const std::string& message, int errorCode);
DISKANN_DLLEXPORT ANNException(const std::string& message, int errorCode,
const std::string& funcSig,
const std::string& fileName,
unsigned int lineNum);

private:
int _errorCode;
};
private:
int _errorCode;
};

class FileException : public ANNException {
public:
DISKANN_DLLEXPORT FileException(const std::string& filename,
std::system_error& e,
const std::string& funcSig,
const std::string& fileName,
unsigned int lineNum);
};
class FileException : public ANNException {
public:
DISKANN_DLLEXPORT FileException(const std::string& filename,
std::system_error& e,
const std::string& funcSig,
const std::string& fileName,
unsigned int lineNum);
};
} // namespace diskann
6 changes: 3 additions & 3 deletions include/boost_dynamic_bitset_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

namespace boost {
#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP
template<typename Block = unsigned long,
typename Allocator = std::allocator<Block>>
class dynamic_bitset;
template <typename Block = unsigned long,
typename Allocator = std::allocator<Block>>
class dynamic_bitset;
#endif
} // namespace boost
20 changes: 6 additions & 14 deletions include/cached_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
#include <iostream>
#include <sstream>

#include "logger.h"
#include "ann_exception.h"
#include "logger.h"

// sequential cached reads
class cached_ifstream {
public:
cached_ifstream() {
}
cached_ifstream() {}
cached_ifstream(const std::string& filename, uint64_t cacheSize)
: cache_size(cacheSize), cur_off(0) {
reader.exceptions(std::ifstream::failbit | std::ifstream::badbit);
Expand Down Expand Up @@ -46,9 +45,7 @@ class cached_ifstream {
}
}

size_t get_file_size() {
return fsize;
}
size_t get_file_size() { return fsize; }

void read(char* read_buf, uint64_t n_bytes) {
assert(cache_buf != nullptr);
Expand Down Expand Up @@ -121,9 +118,7 @@ class cached_ofstream {
}
}

~cached_ofstream() {
this->close();
}
~cached_ofstream() { this->close(); }

void close() {
// dump any remaining data in memory
Expand All @@ -136,14 +131,11 @@ class cached_ofstream {
cache_buf = nullptr;
}

if (writer.is_open())
writer.close();
if (writer.is_open()) writer.close();
diskann::cout << "Finished writing " << fsize << "B" << std::endl;
}

size_t get_file_size() {
return fsize;
}
size_t get_file_size() { return fsize; }
// writes n_bytes from write_buf to the underlying ofstream/cache
void write(char* write_buf, uint64_t n_bytes) {
assert(cache_buf != nullptr);
Expand Down
9 changes: 5 additions & 4 deletions include/common_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#pragma once

#include <fcntl.h>
#include <omp.h>
#include <sys/stat.h>

#include <algorithm>
#include <atomic>
#include <cassert>
Expand All @@ -12,15 +16,12 @@
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fcntl.h>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <omp.h>
#include <iostream>
#include <queue>
#include <random>
#include <set>
#include <shared_mutex>
#include <sys/stat.h>
#include <sstream>
#include <vector>
Loading

0 comments on commit e0281be

Please sign in to comment.