Skip to content

Commit 3b00327

Browse files
MaggieQicheqi
andauthored
Clr core (#376)
* add .net core support * add linux nuget * fix linux nuspec * fix CsharpClient.vcxproj * fix Linux and Windows conflict * fix windows nuget package * add dump and loadfromdump * fix setup.py * fix cuda LOG * fix GPU log * fix Dockerfile for ubuntu20.04 * fix Dockerfile --------- Co-authored-by: cheqi <cheqi@SRGSSD-07>
1 parent fc24d65 commit 3b00327

19 files changed

+249
-162
lines changed

AnnService/inc/Core/Common/cuda/GPUQuantizer.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class GPU_Quantizer {
8989

9090
// Make sure L2 is used, since other
9191
if(metric != DistMetric::L2) {
92-
LOG(Helper::LogLevel::LL_Error, "Only L2 distance currently supported for PQ or OPQ\n");
92+
SPTAGLIB_LOG(Helper::LogLevel::LL_Error, "Only L2 distance currently supported for PQ or OPQ\n");
9393
exit(1);
9494
}
9595

@@ -103,7 +103,7 @@ class GPU_Quantizer {
103103
m_BlockSize = pq_quantizer->GetBlockSize();
104104
m_DimPerSubvector = pq_quantizer->GetDimPerSubvector();
105105

106-
LOG(Helper::LogLevel::LL_Debug, "Using PQ - numSubVectors:%d, KsPerSub:%ld, BlockSize:%ld, DimPerSub:%d, total size of tables:%ld\n", m_NumSubvectors, m_KsPerSubvector, m_BlockSize, m_DimPerSubvector, m_BlockSize*m_NumSubvectors*sizeof(float));
106+
SPTAGLIB_LOG(Helper::LogLevel::LL_Debug, "Using PQ - numSubVectors:%d, KsPerSub:%ld, BlockSize:%ld, DimPerSub:%d, total size of tables:%ld\n", m_NumSubvectors, m_KsPerSubvector, m_BlockSize, m_DimPerSubvector, m_BlockSize*m_NumSubvectors*sizeof(float));
107107

108108
rType = pq_quantizer->GetReconstructType();
109109
CUDA_CHECK(cudaMalloc(&m_DistanceTables, m_BlockSize * m_NumSubvectors * sizeof(float)));
@@ -117,14 +117,14 @@ class GPU_Quantizer {
117117
m_BlockSize = opq_quantizer->GetBlockSize();
118118
m_DimPerSubvector = opq_quantizer->GetDimPerSubvector();
119119

120-
LOG(Helper::LogLevel::LL_Debug, "Using OPQ - numSubVectors:%d, KsPerSub:%ld, BlockSize:%ld, DimPerSub:%d, total size of tables:%ld\n", m_NumSubvectors, m_KsPerSubvector, m_BlockSize, m_DimPerSubvector, m_BlockSize*m_NumSubvectors*sizeof(float));
120+
SPTAGLIB_LOG(Helper::LogLevel::LL_Debug, "Using OPQ - numSubVectors:%d, KsPerSub:%ld, BlockSize:%ld, DimPerSub:%d, total size of tables:%ld\n", m_NumSubvectors, m_KsPerSubvector, m_BlockSize, m_DimPerSubvector, m_BlockSize*m_NumSubvectors*sizeof(float));
121121

122122
rType = opq_quantizer->GetReconstructType();
123123
CUDA_CHECK(cudaMalloc(&m_DistanceTables, m_BlockSize * m_NumSubvectors * sizeof(float)));
124124
CUDA_CHECK(cudaMemcpy(m_DistanceTables, opq_quantizer->GetL2DistanceTables(), m_BlockSize*m_NumSubvectors*sizeof(float), cudaMemcpyHostToDevice));
125125
}
126126
else {
127-
LOG(Helper::LogLevel::LL_Error, "Only PQ and OPQ quantizers are supported for GPU build\n");
127+
SPTAGLIB_LOG(Helper::LogLevel::LL_Error, "Only PQ and OPQ quantizers are supported for GPU build\n");
128128
exit(1);
129129
}
130130

AnnService/inc/Core/Common/cuda/KNN.hxx

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

AnnService/inc/Core/Common/cuda/Refine.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void refineGraphGPU(SPTAG::VectorIndex* index, Point<T,SUMTYPE,MAX_DIM>* d_point
396396
cudaMemcpy(d_candidates, candidates, dataSize*candidatesPerVector*sizeof(int), cudaMemcpyHostToDevice);
397397
398398
auto t2 = std::chrono::high_resolution_clock::now();
399-
LOG(SPTAG::Helper::LogLevel::LL_Info, "find candidates time (ms): %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count());
399+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Info, "find candidates time (ms): %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count());
400400
401401
// Use a number of batches of refinement to overlap CPU and GPU work (TODO)
402402
int NUM_BATCHES = 1;
@@ -414,13 +414,13 @@ void refineGraphGPU(SPTAG::VectorIndex* index, Point<T,SUMTYPE,MAX_DIM>* d_point
414414
refineBatch_kernel<T,SUMTYPE,MAX_DIM, REFINE_THREADS><<<REFINE_BLOCKS,REFINE_THREADS>>>(d_points, batch_size, i*batch_size, d_graph, d_candidates, listMem, candidatesPerVector, KVAL, refineDepth, metric);
415415
cudaError_t status = cudaDeviceSynchronize();
416416
if(status != cudaSuccess) {
417-
LOG(SPTAG::Helper::LogLevel::LL_Error, "Refine error code:%d\n", status);
417+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Error, "Refine error code:%d\n", status);
418418
}
419419
}
420420
421421
}
422422
t2 = std::chrono::high_resolution_clock::now();
423-
LOG(SPTAG::Helper::LogLevel::LL_Info, "GPU refine time (ms): %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count());
423+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Info, "GPU refine time (ms): %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count());
424424
425425
cudaFree(listMem);
426426
cudaFree(d_candidates);

AnnService/inc/Core/Common/cuda/TPtree.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ __host__ void construct_trees_PQ(TPtree** d_trees, PointSet<T>** ps, int N, int
379379
size_t freeMem, totalMem;
380380
CUDA_CHECK(cudaMemGetInfo(&freeMem, &totalMem));
381381
size_t neededMem = N*reconDim*sizeof(R);
382-
LOG(SPTAG::Helper::LogLevel::LL_Debug, "Memory needed for reconstructed vectors to build TPT: %ld, memory availalbe: %ld\n", neededMem, totalMem);
382+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Debug, "Memory needed for reconstructed vectors to build TPT: %ld, memory availalbe: %ld\n", neededMem, totalMem);
383383
if(freeMem*0.9 < neededMem) {
384-
LOG(SPTAG::Helper::LogLevel::LL_Error, "Insufficient memory for reconstructed vectors to build TPTree.\n");
384+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Error, "Insufficient memory for reconstructed vectors to build TPTree.\n");
385385
exit(1);
386386
}
387387

@@ -432,7 +432,7 @@ printf("Num leaves:%d, min leaf:%d, max leaf:%d\n", d_trees[0]->num_leaves, min_
432432
433433
cudaDeviceProp prop;
434434
CUDA_CHECK(cudaGetDeviceProperties(&prop, gpuNum)); // Get avil. memory
435-
LOG(SPTAG::Helper::LogLevel::LL_Info, "GPU %d - %s\n", gpuNum, prop.name);
435+
SPTAGLIB_LOG(SPTAG::Helper::LogLevel::LL_Info, "GPU %d - %s\n", gpuNum, prop.name);
436436
437437
size_t freeMem, totalMem;
438438
CUDA_CHECK(cudaMemGetInfo(&freeMem, &totalMem));

0 commit comments

Comments
 (0)