Skip to content

Comments

Shaders precompile instead of compiling on the fly#83

Merged
moven0831 merged 2 commits intozkmopro:feat/example-ios-appfrom
yaroslavyaroslav:shaders-precompile
Jun 5, 2025
Merged

Shaders precompile instead of compiling on the fly#83
moven0831 merged 2 commits intozkmopro:feat/example-ios-appfrom
yaroslavyaroslav:shaders-precompile

Conversation

@yaroslavyaroslav
Copy link
Collaborator

Closes: #77

@yaroslavyaroslav yaroslavyaroslav changed the base branch from main to feat/example-ios-app June 4, 2025 21:10
let constants = get_or_calc_constants(config.num_limbs, config.log_limb_size);

// Pre-write constants to avoid doing it on every shader execution
write_constants(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moven0831 please check if this function call can be deleted here.

Copy link
Collaborator

@moven0831 moven0831 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall works great to boost an executable iOS app after some local patches about the metal_msm.rs.

for pbpr stages, we need a dummy u32 for params_buf encoding to align with the Metal's 16-byte style uint3. if not, the error goes like

validateComputeFunctionArguments:1683: failed assertion 'Compute Function(bpr_stage_1): argument params[0] from buffer(6) with offset(0) and length(12) has space for 12 bytes, but argument has a length(16).'

use std::collections::HashMap;
use std::sync::Mutex;
// Embed the precompiled Metal library
include!(concat!(env!("OUT_DIR"), "/built_shaders.rs"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern works well for the ultimate metal_msm execution but fail the current cargo test since some of the unit tests still relies on the compiling-on-the-fly pattern

@moven0831 moven0831 merged commit 56c4d91 into zkmopro:feat/example-ios-app Jun 5, 2025
@moven0831
Copy link
Collaborator

@yaroslavyaroslav yaroslavyaroslav deleted the shaders-precompile branch June 5, 2025 04:45
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.

[iOS] Crash: EPERM when xcrun metal runs at runtime

2 participants