CandidateVectorSearch 1.7.2
Searching for peptide candidates using sparse matrix + matrix/vector multiplication.
Loading...
Searching...
No Matches
DataLoader.cs
Go to the documentation of this file.
1using System.Diagnostics;
2using System.Runtime.InteropServices;
3
5{
9 public partial class DataLoader
10 {
14 const int MASS_RANGE = 5000;
15
19 const int MASS_MULTIPLIER = 100;
20
24 const int ENCODING_SIZE = MASS_RANGE * MASS_MULTIPLIER;
25
29 const bool NORMALIZE = true;
30
34 const bool USE_GAUSSIAN = true;
35
43 public static void Main(string[] args)
44 {
45 // parameter defaults
46 var mode = "Eigen";
47 var nrCandidates = 5000000;
48 var nrSpectra = 199;
49 var topN = 20;
50 var batchSize = 100;
51 //var seed = 1337;
52 var r = new Random(); //new Random(seed);
53
54 // parse arguments
55 if (args.Length > 0)
56 {
57 mode = args[0];
58 }
59 if (args.Length > 1)
60 {
61 nrCandidates = int.Parse(args[1]);
62 }
63 if (args.Length > 2)
64 {
65 nrSpectra = int.Parse(args[2]);
66 }
67 if (args.Length > 3)
68 {
69 topN = int.Parse(args[3]);
70 }
71 if (args.Length > 4)
72 {
73 batchSize = int.Parse(args[4]);
74 }
75
76 // call subroutine for specified mode
77 if (mode == "Cuda")
78 {
79 var status = Cuda(nrCandidates, nrSpectra, topN, batchSize, r, false, 1);
80 Console.WriteLine($"Cuda routine exited with status: {status}");
81 }
82 else if (mode == "CudaB")
83 {
84 var status = Cuda(nrCandidates, nrSpectra, topN, batchSize, r, true, 1);
85 Console.WriteLine($"Cuda routine exited with status: {status}");
86 }
87 else if (mode == "CudaBAlt")
88 {
89 var status = Cuda(nrCandidates, nrSpectra, topN, batchSize, r, true, 2);
90 Console.WriteLine($"Cuda routine exited with status: {status}");
91 }
92 else if (mode == "Eigen")
93 {
94 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, false, false);
95 Console.WriteLine($"Eigen routine exited with status: {status}");
96 }
97 else if (mode == "EigenInt")
98 {
99 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, false, false, true);
100 Console.WriteLine($"Eigen routine exited with status: {status}");
101 }
102 else if (mode == "EigenB")
103 {
104 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, true, false);
105 Console.WriteLine($"Eigen routine exited with status: {status}");
106 }
107 else if (mode == "EigenIntB")
108 {
109 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, true, false, true);
110 Console.WriteLine($"Eigen routine exited with status: {status}");
111 }
112 else if (mode == "EigenS")
113 {
114 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, false, true);
115 Console.WriteLine($"Eigen routine exited with status: {status}");
116 }
117 else if (mode == "EigenSInt")
118 {
119 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, false, true, true);
120 Console.WriteLine($"Eigen routine exited with status: {status}");
121 }
122 else if (mode == "EigenSB")
123 {
124 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, true, true);
125 Console.WriteLine($"Eigen routine exited with status: {status}");
126 }
127 else if (mode == "EigenSIntB")
128 {
129 var status = Eigen(nrCandidates, nrSpectra, topN, batchSize, r, true, true, true);
130 Console.WriteLine($"Eigen routine exited with status: {status}");
131 }
132 else if (mode == "Benchmark")
133 {
134 var status = Benchmark(nrCandidates, nrSpectra, topN, batchSize, r);
135 Console.WriteLine($"Compare routine exited with status: {status}");
136 }
137 else if (mode == "Compare")
138 {
139 var status = Compare(nrCandidates, nrSpectra, topN, batchSize, r);
140 Console.WriteLine($"Compare routine exited with status: {status}");
141 }
142 else if (mode == "CompareD")
143 {
144 var status = DeterministicCompare();
145 Console.WriteLine($"Deterministic compare routine exited with status: {status}");
146 }
147 else
148 {
149 Console.WriteLine("No mode selected, has to be one of: Eigen(S)(Int), Eigen(S)(Int)B, Cuda(B/BAlt), Compare, Benchmark.");
150 }
151
152 Console.WriteLine("Done!");
153
154 return;
155 }
156 }
157}
static int Cuda(int nrCandidates, int nrSpectra, int topN, int batchSize, Random r, bool batched, int batchMode)
Wrapper for testing GPU-based matrix multiplication functions.
Definition Cuda.cs:52
static int Benchmark(int nrCandidates, int nrSpectra, int topN, int batchSize, Random r)
Function to run synthetic benchmarks of all the different matrix multiplication functions.
Definition Benchmark.cs:17
static int DeterministicCompare()
[DEPRECATED] Function for testing a simple matrix multiplication of a deterministic problem....
static int Eigen(int nrCandidates, int nrSpectra, int topN, int batchSize, Random r, bool batched, bool sparse, bool useInt=false)
Wrapper for testing CPU-based matrix multiplication functions.
Definition Eigen.cs:100
static int Compare(int nrCandidates, int nrSpectra, int topN, int batchSize, Random r)
Function to compare the results of all the different matrix multiplication functions.
Definition Compare.cs:17
static void Main(string[] args)
Main function to be executed when calling the executable. The routine to be called depends on the com...
Definition DataLoader.cs:43
const int MASS_MULTIPLIER
const int MASS_RANGE