-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticTranslator.h
More file actions
70 lines (60 loc) · 2.48 KB
/
StaticTranslator.h
File metadata and controls
70 lines (60 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include "WordSet.h"
#include "Mapping.h"
#include <vector>
#include <string>
// Static translator interface - no instances needed, all methods are static
class StaticTranslator {
public:
// Translation statistics
struct TranslationStats {
size_t wordsTranslated;
double translationTimeMs;
double throughputWordsPerSecond;
size_t threadsUsed;
std::string implementationType;
};
// Main translation methods
static WordSet translateWordSet(const WordSet& evaWords, const Mapping& mapping, bool useCuda = false);
static WordSet translateWordSetWithStats(const WordSet& evaWords, const Mapping& mapping, TranslationStats& stats, bool useCuda = false);
// Utility methods
static bool validateInputAlphabet(const WordSet& words);
static std::string getCudaDeviceInfo();
static bool isCudaAvailable();
// Matrix conversion utilities (public for batch processing)
static std::vector<std::vector<int>> wordSetToMatrix(const WordSet& words);
static WordSet matrixToWordSet(
const std::vector<std::vector<int>>& matrix,
const WordSet& originalWords,
Alphabet targetAlphabet
);
// High-performance batch processing for multiple mappings
static void performBatchMatrixMultiplicationCuda(
const std::vector<std::vector<int>>& inputMatrix,
const std::vector<std::vector<std::vector<int>>>& transformMatrices,
std::vector<std::vector<std::vector<int>>>& resultMatrices
);
private:
// Internal utility methods
static std::wstring binaryToHebrewText(const std::vector<int>& binaryVector);
static size_t getOptimalThreadCount();
// Core matrix multiplication implementations
static void performMatrixMultiplicationCpu(
const std::vector<std::vector<int>>& inputMatrix,
const std::vector<std::vector<int>>& transformMatrix,
std::vector<std::vector<int>>& resultMatrix
);
static void performMatrixMultiplicationCuda(
const std::vector<std::vector<int>>& inputMatrix,
const std::vector<std::vector<int>>& transformMatrix,
std::vector<std::vector<int>>& resultMatrix
);
// CPU-specific optimized batch processing
static void matrixMultiplyBatch(
const std::vector<std::vector<int>>& inputMatrix,
const std::vector<std::vector<int>>& transformMatrix,
std::vector<std::vector<int>>& resultMatrix,
size_t startRow,
size_t endRow
);
};