Files
aitbc/migration_examples/basic_migration.py
oib f353e00172 chore(security): enhance environment configuration, CI workflows, and wallet daemon with security improvements
- Restructure .env.example with security-focused documentation, service-specific environment file references, and AWS Secrets Manager integration
- Update CLI tests workflow to single Python 3.13 version, add pytest-mock dependency, and consolidate test execution with coverage
- Add comprehensive security validation to package publishing workflow with manual approval gates, secret scanning, and release
2026-03-03 10:33:46 +01:00

41 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""
Basic Migration Example
Shows how to migrate from direct CUDA calls to the new abstraction layer.
"""
# BEFORE (Direct CUDA)
# from high_performance_cuda_accelerator import HighPerformanceCUDAZKAccelerator
#
# accelerator = HighPerformanceCUDAZKAccelerator()
# if accelerator.initialized:
# result = accelerator.field_add_cuda(a, b)
# AFTER (Abstraction Layer)
import numpy as np
from gpu_acceleration import GPUAccelerationManager, create_gpu_manager
# Method 1: Auto-detect backend
gpu = create_gpu_manager()
gpu.initialize()
a = np.array([1, 2, 3, 4], dtype=np.uint64)
b = np.array([5, 6, 7, 8], dtype=np.uint64)
result = gpu.field_add(a, b)
print(f"Field addition result: {result}")
# Method 2: Context manager (recommended)
from gpu_acceleration import GPUAccelerationContext
with GPUAccelerationContext() as gpu:
result = gpu.field_mul(a, b)
print(f"Field multiplication result: {result}")
# Method 3: Quick functions
from gpu_acceleration import quick_field_add
result = quick_field_add(a, b)
print(f"Quick field addition: {result}")