Every time I build and run my CUDAfy code, it takes considerable time for loading the module and translating it. Is there any way to reduce the time taken during translation and loading?
It may not be desirable to always call Cudafy if the GPU code has not been changed. You can cache the Cudafy modules by using serialization.
CudafyModule km = CudafyModule.TryDeserialize();
if (km == null || !km.TryVerifyChecksums())
{
km = CudafyTranslator.Cudafy();
km.Serialize();
}
The TryDeserialize method will attempt to find a *.cdfy file in the current directory with the same file name as the calling type. If this is not found or fails then null is returned and try making a new module.If it is not null then check whether the cached module refers to the same version of the .NET code it was created from. To do this call TryVerifyChecksums. If this returns false then it means the cached module was out of date and it is advisable to cudafy a new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With