Skip to content

feat: metal kernels & tests#15

Open
heswithme wants to merge 1 commit intoHrikB:masterfrom
heswithme:metal-implementation
Open

feat: metal kernels & tests#15
heswithme wants to merge 1 commit intoHrikB:masterfrom
heswithme:metal-implementation

Conversation

@heswithme
Copy link

Metal Support for CreateXCrunch

Changes Overview

This PR adds Metal GPU support for Apple Silicon (M1, M2, M3, etc.) devices while maintaining full backward compatibility.

Modified Files (6):

  1. Cargo.toml - Added macOS-specific Metal dependencies
  2. src/cli.rs - Added --metal flag (defaults to false)
  3. src/lib.rs - Added use_metal field to Config struct and conditional module imports
  4. src/main.rs - Added conditional routing to Metal or OpenCL based on platform and flag
  5. tests/test.rs - Added use_metal: false field (can be changed to true for Metal testing)
  6. Cargo.lock - Updated with new dependencies

New Files (4):

  1. src/metal_gpu.rs - Metal GPU implementation
  2. src/metal_kernel.rs - Metal kernel generation
  3. src/kernels/metal/keccak256_template.metal - Metal shader template
  4. tests/metal_test.rs - Metal-specific unit tests

Key Features

  • Opt-in: Metal support is disabled by default, enabled with --metal flag
  • Platform-specific: Only compiles on macOS, shows error on other platforms
  • Full feature parity: Supports all existing features (CREATE2/3, all reward types)
  • Performance: ~60M attempts/sec on M2 Pro with 99% GPU utilization
  • Minimal changes: Existing code paths unchanged when Metal not used

Testing

To test Metal support in existing tests:

// In tests/test.rs, change:
use_metal: false,
// to:
use_metal: true,

Usage

./target/release/createxcrunch create3 --metal --caller 0x... --leading 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant