Skip to content
Open
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
2 changes: 2 additions & 0 deletions BENCHMARKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ These kernels DO NOT do a KNN search query. The only work measured is the distan
- SIMD+L2: ```/benchmarks/KernelNaryL2```
- SIMD+IP: ```/benchmarks/KernelNaryIP```

*Only support vector element type of float32, for other types like uint8, checkout the updates on branch `main`*

All these executables have two obligatory parameters:
- `<n_vector>` and `<dimension>`. These determine the random collection to be used for the test. The values are limited to: `n_vectors=(64 128 512 1024 4096 8192 16384 65536 131072 262144 1048576)`,
`dimensions=(8 16 32 64 128 192 256 384 512 768 1024 1536 2048 4096 8192)`.
Expand Down
9 changes: 1 addition & 8 deletions benchmarks/bench_kernels/nary_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << distances[N_VECTORS-1] << "\n"; // Dummy print so the compiler does the job

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
9 changes: 1 addition & 8 deletions benchmarks/bench_kernels/nary_l1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << distances[N_VECTORS-1] << "\n"; // Dummy print so the compiler does the job

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
9 changes: 1 addition & 8 deletions benchmarks/bench_kernels/nary_l2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << distances[N_VECTORS-1] << "\n"; // Dummy print so the compiler does the job

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
13 changes: 4 additions & 9 deletions benchmarks/bench_kernels/pdx_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -25,7 +26,8 @@ int main(int argc, char *argv[]) {
std::cout << "RUNS: " << NUM_MEASURE_RUNS << "\n";

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_IP.csv";
std::string filename = std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -65,13 +67,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << PDXScanner<PDX::IP>::distances[PDXScanner<>::PDX_VECTOR_SIZE - 1] << "\n";

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
13 changes: 4 additions & 9 deletions benchmarks/bench_kernels/pdx_l1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L1.csv";

std::string filename = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION) + "-pdx";
std::string filename = std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -66,13 +68,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << PDXScanner<PDX::L1>::distances[PDXScanner<>::PDX_VECTOR_SIZE - 1] << "\n";

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
13 changes: 4 additions & 9 deletions benchmarks/bench_kernels/pdx_l2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -30,7 +31,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_GATHER_PDX_L2.csv";

std::string filename = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION) + "-pdx";
std::string filename = std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -68,13 +70,6 @@ int main(int argc, char *argv[]) {
std::cout << std::setprecision(16) << PDXScanner<PDX::L2>::distances[PDXScanner<>::PDX_VECTOR_SIZE - 1] << "\n";

BenchmarkMetadata results_metadata = {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
0,
0
};
dataset, ALGORITHM, NUM_MEASURE_RUNS, 1, 1, 0, 0};
BenchmarkUtils::SaveResults(runtimes, RESULTS_PATH, results_metadata);
}
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_128.csv";

std::string filename = "128x" + std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = "128x" + std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_16.csv";

std::string filename = "16x" + std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = "16x" + std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_256.csv";

std::string filename = "256x" + std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = "256x" + std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_32.csv";

std::string filename = "32x" + std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = "32x" + std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_512.csv";

std::string filename = "512x" + std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = "512x" + std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/bench_kernels/pdx_l2_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) {
std::string ALGORITHM = "pdx";
size_t DIMENSION;
size_t N_VECTORS;
std::string dtype = "float32";
if (argc > 1){
N_VECTORS = atoi(argv[1]);
}
Expand All @@ -26,7 +27,8 @@ int main(int argc, char *argv[]) {

std::string RESULTS_PATH = BENCHMARK_UTILS.RESULTS_DIR_PATH + "PURESCAN_PDX_L2_64.csv";

std::string filename = std::to_string(N_VECTORS) + "x"+ std::to_string(DIMENSION) + "-pdx";
std::string filename = std::to_string(N_VECTORS) + "x" +
std::to_string(DIMENSION) + "-pdx-" + dtype;
std::string dataset = std::to_string(N_VECTORS) + "x" + std::to_string(DIMENSION);

float *raw_data = MmapFile32( BenchmarkUtils::PURESCAN_DATA + filename);
Expand Down Expand Up @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) {
dataset,
ALGORITHM,
NUM_MEASURE_RUNS,
NUM_WARMUP_RUNS,
1,
1,
0,
0
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/python_scripts/setup_purescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

# Setup random collections of vectors with PDX and Nary
def generate_synthetic_data(BLOCK_SIZES=(), dimensions=(), vectors=(), dtype=np.float32):
if dtype not in [np.float32]:
# for more dtype support, checkout the updates on the `main` branch
raise ValueError('dtype must be np.float32')

type_size = np.dtype(dtype).itemsize
adaptive_block_size = int(256 / type_size) # 256 bytes can fit in registers across architectures
print('Block size =', adaptive_block_size)
Expand Down