Skip to content

Commit

Permalink
Merge pull request #3 from hgb-bin-proteomics/develop
Browse files Browse the repository at this point in the history
fix compiler options
  • Loading branch information
michabirklbauer authored Jul 14, 2023
2 parents 22a27f1 + 0551f00 commit 611df23
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
14 changes: 9 additions & 5 deletions DataLoader/Eigen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ public partial class DataLoader
{
const string dll = @"VectorSearch.dll";
[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr findTopCandidates(IntPtr cV, IntPtr cI, IntPtr sV, IntPtr sI,
int cVL, int cIL, int sVL, int sIL,
private static extern IntPtr findTopCandidates(IntPtr cV, IntPtr cI,
IntPtr sV, IntPtr sI,
int cVL, int cIL,
int sVL, int sIL,
int n, float tolerance);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -87,9 +89,11 @@ public static int Eigen(int nrCandidates, int nrSpectra, int topN, Random r)
IntPtr sValuesPtr = sValuesLoc.AddrOfPinnedObject();
IntPtr sIdxPtr = sIdxLoc.AddrOfPinnedObject();

IntPtr result = findTopCandidates(cValuesPtr, cIdxPtr, sValuesPtr, sIdxPtr,
candidateValues.Length, candidatesIdx.Length, spectraValues.Length, spectraIdx.Length,
topN, (float)0.02);
IntPtr result = findTopCandidates(cValuesPtr, cIdxPtr,
sValuesPtr, sIdxPtr,
candidateValues.Length, candidatesIdx.Length,
spectraValues.Length, spectraIdx.Length,
topN, (float) 0.02);

Marshal.Copy(result, resultArray, 0, spectraIdx.Length * topN);

Expand Down
8 changes: 4 additions & 4 deletions VectorSearch/VectorSearch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,30 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
15 changes: 10 additions & 5 deletions VectorSearch/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <iostream>

const int versionMajor = 1;
const int versionMinor = 1;
const int versionMinor = 2;
const int versionFix = 0;

#define METHOD_EXPORTS
Expand All @@ -23,8 +23,10 @@ const int APPROX_NNZ_PER_ROW = 100;
const double ONE_OVER_SQRT_PI = 0.39894228040143267793994605993438;

extern "C" {
EXPORT int* findTopCandidates(int*, int*, int*, int*,
int, int, int, int,
EXPORT int* findTopCandidates(int*, int*,
int*, int*,
int, int,
int, int,
int, float);

EXPORT int releaseMemory(int*);
Expand All @@ -47,8 +49,10 @@ float normpdf(float, float, float);
/// <param name="n">How many of the best hits should be returned (int).</param>
/// <param name="tolerance">Tolerance for peak matching (float).</param>
/// <returns>An integer array of length sILength * n containing the indexes of the top n candidates for each spectrum.</returns>
int* findTopCandidates(int* candidatesValues, int* candidatesIdx, int* spectraValues, int* spectraIdx,
int cVLength, int cILength, int sVLength, int sILength,
int* findTopCandidates(int* candidatesValues, int* candidatesIdx,
int* spectraValues, int* spectraIdx,
int cVLength, int cILength,
int sVLength, int sILength,
int n, float tolerance) {

std::cout << "Running Eigen vector search version " << versionMajor << "." << versionMinor << "." << versionFix << std::endl;
Expand Down Expand Up @@ -79,6 +83,7 @@ int* findTopCandidates(int* candidatesValues, int* candidatesIdx, int* spectraVa
int startIter = spectraIdx[i];
int endIter = i + 1 == sILength ? sVLength : spectraIdx[i + 1];
auto* v = new Eigen::SparseVector<float, Eigen::ColMajor>(ENCODING_SIZE);
v->reserve(APPROX_NNZ_PER_ROW);
for (int j = startIter; j < endIter; ++j) {
auto currentPeak = spectraValues[j];
auto minPeak = currentPeak - t > 0 ? currentPeak - t : 0;
Expand Down
1 change: 0 additions & 1 deletion VectorSearchCUDA/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ float normpdf(float x, float mu, float sigma) {
return (ONE_OVER_SQRT_PI / sigma) * exp(-0.5 * squared((x - mu) / sigma));
}


BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
Expand Down
Binary file modified dll/VectorSearch.dll
Binary file not shown.
Binary file modified dll/VectorSearchCUDA.dll
Binary file not shown.

0 comments on commit 611df23

Please sign in to comment.