superaugment
Version:
Enterprise-grade MCP server with world-class C++ analysis, robust error handling, and production-ready architecture for VS Code Augment
214 lines • 6.18 kB
TypeScript
/**
* CUDA Code Analyzer
*
* Specialized analyzer for CUDA C/C++ code including kernel analysis,
* memory management, performance optimization, and BSGS algorithm support.
*/
/**
* CUDA analysis result interface
*/
export interface CudaAnalysisResult {
summary: {
totalKernels: number;
totalDeviceFunctions: number;
memoryTransfers: number;
sharedMemoryUsage: number;
registerUsage: number;
};
kernels: CudaKernel[];
deviceFunctions: CudaDeviceFunction[];
memoryOperations: CudaMemoryOperation[];
optimizations: CudaOptimization[];
bsgs?: BsgsAnalysis;
performance: {
occupancy: OccupancyAnalysis;
memoryBandwidth: MemoryBandwidthAnalysis;
computeIntensity: ComputeIntensityAnalysis;
};
issues: CudaIssue[];
recommendations: string[];
}
export interface CudaKernel {
name: string;
line: number;
column: number;
gridDim: LaunchDimension;
blockDim: LaunchDimension;
sharedMemory: number;
stream?: string;
parameters: CudaParameter[];
complexity: number;
memoryAccess: MemoryAccessPattern[];
syncPoints: SynchronizationPoint[];
estimatedOccupancy: number;
registerPressure: number;
memoryCoalescing: CoalescingAnalysis;
isBsgsKernel: boolean;
bsgsCharacteristics?: BsgsKernelCharacteristics;
}
export interface CudaDeviceFunction {
name: string;
line: number;
column: number;
isInline: boolean;
parameters: CudaParameter[];
calledBy: string[];
}
export interface CudaParameter {
name: string;
type: string;
isPointer: boolean;
isConst: boolean;
isRestrict: boolean;
memorySpace: 'global' | 'shared' | 'constant' | 'texture' | 'local' | 'register';
}
export interface LaunchDimension {
x: string;
y?: string;
z?: string;
isDynamic: boolean;
}
export interface CudaMemoryOperation {
type: 'cudaMalloc' | 'cudaFree' | 'cudaMemcpy' | 'cudaMemcpyAsync' | 'cudaMemset';
line: number;
column: number;
size?: string;
direction?: 'H2D' | 'D2H' | 'D2D';
isAsync: boolean;
stream?: string;
}
export interface MemoryAccessPattern {
type: 'coalesced' | 'strided' | 'random' | 'broadcast';
line: number;
variable: string;
efficiency: number;
}
export interface SynchronizationPoint {
type: '__syncthreads' | '__syncwarp' | 'cudaDeviceSynchronize' | 'cudaStreamSynchronize';
line: number;
column: number;
scope: 'block' | 'warp' | 'device' | 'stream';
}
export interface CoalescingAnalysis {
score: number;
issues: string[];
recommendations: string[];
}
export interface OccupancyAnalysis {
theoretical: number;
achieved: number;
limitingFactor: 'registers' | 'shared_memory' | 'blocks' | 'warps';
recommendations: string[];
}
export interface MemoryBandwidthAnalysis {
utilization: number;
bottlenecks: string[];
recommendations: string[];
}
export interface ComputeIntensityAnalysis {
ratio: number;
classification: 'memory_bound' | 'compute_bound' | 'balanced';
recommendations: string[];
}
export interface CudaOptimization {
type: 'memory' | 'compute' | 'occupancy' | 'synchronization';
priority: 'low' | 'medium' | 'high' | 'critical';
description: string;
benefit: string;
effort: 'low' | 'medium' | 'high';
locations: number[];
}
export interface CudaIssue {
type: 'race_condition' | 'deadlock' | 'memory_leak' | 'uncoalesced_access' | 'bank_conflict';
severity: 'low' | 'medium' | 'high' | 'critical';
line: number;
column: number;
description: string;
fix: string;
}
export interface BsgsAnalysis {
isImplemented: boolean;
algorithm: 'baby_step_giant_step' | 'pollard_rho' | 'pohlig_hellman' | 'other';
characteristics: BsgsCharacteristics;
optimizations: BsgsOptimization[];
performance: BsgsPerformance;
}
export interface BsgsCharacteristics {
babySteps: number;
giantSteps: number;
memoryUsage: string;
parallelization: 'thread_level' | 'block_level' | 'grid_level' | 'none';
dataStructure: 'hash_table' | 'sorted_array' | 'binary_tree' | 'other';
}
export interface BsgsKernelCharacteristics {
phase: 'baby_steps' | 'giant_steps' | 'collision_detection' | 'preprocessing';
memoryPattern: 'sequential' | 'random' | 'strided';
computeIntensity: 'low' | 'medium' | 'high';
synchronizationNeeds: 'none' | 'block' | 'grid';
}
export interface BsgsOptimization {
type: 'memory_layout' | 'parallelization' | 'algorithm' | 'data_structure';
description: string;
benefit: string;
implementation: string;
}
export interface BsgsPerformance {
estimatedSpeedup: number;
memoryEfficiency: number;
scalability: 'poor' | 'fair' | 'good' | 'excellent';
bottlenecks: string[];
}
/**
* CUDA Code Analyzer
*/
export declare class CudaAnalyzer {
private fileSystemManager;
constructor();
/**
* Analyze CUDA file
*/
analyzeFile(filePath: string): Promise<CudaAnalysisResult>;
/**
* Analyze CUDA kernels
*/
private analyzeKernels;
/**
* Analyze device functions
*/
private analyzeDeviceFunctions;
/**
* Analyze memory operations
*/
private analyzeMemoryOperations;
/**
* Analyze BSGS patterns
*/
private analyzeBsgsPatterns;
/**
* Analyze performance characteristics
*/
private analyzePerformance;
/**
* Detect common CUDA issues
*/
private detectIssues;
/**
* Generate optimization recommendations
*/
private generateOptimizations;
private parseKernelParameters;
private parseLaunchConfiguration;
private parseMemcpyDirection;
private parseMemcpySize;
private detectBsgsKernel;
private analyzeBsgsKernel;
private detectBsgsAlgorithm;
private analyzeBsgsCharacteristics;
private generateBsgsOptimizations;
private analyzeBsgsPerformance;
private analyzeOccupancy;
private analyzeMemoryBandwidth;
private analyzeComputeIntensity;
private detectUncoalescedAccess;
}
//# sourceMappingURL=CudaAnalyzer.d.ts.map