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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dist/*
*egg-info

node_modules
bindings/nodejs/vectorlite/package-lock.json_codeql_detected_source_root
bindings/nodejs/vectorlite/package-lock.json
_codeql_detected_source_root
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Please note vectorlite is currently in beta. There could be breaking changes.
### Free-standing Application Defined SQL functions
The following functions can be used in any context.
``` sql
vectorlite_info() -- prints version info and some compile time info. e.g. Is SSE, AVX enabled.
vectorlite_info() -- prints version info and the best SIMD target chosen by Highway at runtime.
vector_from_json(json_string) -- converts a json array of type TEXT into BLOB(a c-style float32 array)
vector_to_json(vector_blob) -- converts a vector of type BLOB(c-style float32 array) into a json array of type TEXT
vector_distance(vector_blob1, vector_blob2, distance_type_str) -- calculate vector distance between two vectors, distance_type_str could be 'l2', 'cosine', 'ip'
Expand Down
1 change: 1 addition & 0 deletions bindings/python/vectorlite_py/test/vectorlite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_vectorlite_info(conn):
cur.execute('select vectorlite_info()')
output = cur.fetchone()
assert f'vectorlite extension version {vectorlite_py.__version__}' in output[0]
assert 'Best SIMD target in use:' in output[0]

def test_virtual_table_happy_path(conn, random_vectors):
# Note: if space is '', it will be treated as 'l2'
Expand Down
2 changes: 1 addition & 1 deletion doc/markdown/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please note vectorlite is currently in beta. There could be breaking changes.
## Free-standing Application Defined SQL functions
The following functions can be used in any context.
``` sql
vectorlite_info() -- prints version info and some compile time info. e.g. Is SSE, AVX enabled.
vectorlite_info() -- prints version info and the best SIMD target chosen by Highway at runtime.
vector_from_json(json_string) -- converts a json array of type TEXT into BLOB(a c-style float32 array)
vector_to_json(vector_blob) -- converts a vector of type BLOB(c-style float32 array) into a json array of type TEXT
vector_distance(vector_blob1, vector_blob2, distance_type_str) -- calculate vector distance between two vectors, distance_type_str could be 'l2', 'cosine', 'ip'
Expand Down
8 changes: 8 additions & 0 deletions vectorlite/ops/ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,14 @@ HWY_DLLEXPORT std::vector<const char*> GetSupportedTargets() {
return target_names;
}

HWY_DLLEXPORT const char* GetBestTarget() {
std::vector<int64_t> targets = hwy::SupportedAndGeneratedTargets();
if (targets.empty()) {
return "Unknown";
}
return hwy::TargetName(targets[0]);
}

HWY_DLLEXPORT void QuantizeF32ToF16(const float* HWY_RESTRICT in,
hwy::float16_t* HWY_RESTRICT out,
size_t num_elements) {
Expand Down
5 changes: 4 additions & 1 deletion vectorlite/ops/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ HWY_DLLEXPORT void Normalize_Scalar(hwy::float16_t* HWY_RESTRICT inout,
size_t num_elements);

// Get supported SIMD target name strings.
HWY_DLLEXPORT std::vector<const char*> GetSuppportedTargets();
HWY_DLLEXPORT std::vector<const char*> GetSupportedTargets();

// Get the best SIMD target chosen by Highway at runtime.
HWY_DLLEXPORT const char* GetBestTarget();

// in and out should not be nullptr and points to valid memory of required size.
HWY_DLLEXPORT void QuantizeF32ToF16(const float* HWY_RESTRICT in,
Expand Down
9 changes: 5 additions & 4 deletions vectorlite/sqlite_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "util.h"
#include "ops/ops.h"
#include "vector.h"
#include "vector_space.h"
#include "vectorlite/version.h"
Expand All @@ -17,10 +17,11 @@ extern const sqlite3_api_routines *sqlite3_api;
namespace vectorlite {

void ShowInfo(sqlite3_context *ctx, int, sqlite3_value **) {
auto simd = vectorlite::DetectSIMD().value_or("SIMD not enabled");
const char *best_target = vectorlite::ops::GetBestTarget();
std::string info =
absl::StrFormat("vectorlite extension version %s, built with %s",
VECTORLITE_VERSION, simd);
absl::StrFormat("vectorlite extension version %s. "
"Best SIMD target in use: %s",
VECTORLITE_VERSION, best_target);
DLOG(INFO) << "ShowInfo called: " << info;
sqlite3_result_text(ctx, info.c_str(), -1, SQLITE_TRANSIENT);
}
Expand Down
Loading