         }
         /// If not cached, compile using NVRTC
         log("Loading CUDA kernel \'\(source) \(operation)\' for \(T.self)...\n")
-        let ptx = try! Compiler.compile(
-            source.rawValue,
-            options: [
-                .computeCapability(device.computeCapability),
-                .useFastMath,
-                .disableWarnings,
-                .defineMacro("KERNEL", as: String(describing: source)),
-                .defineMacro("TYPE", as: T.kernelDataType.rawValue),
-                .defineMacro("OP(_x_, _y_)", as: operation.source)
-            ]
-        )
-        var function: Function!
-        device.sync {
-            let module = try! Module(ptx: ptx)
-            function = module.function(named: String(describing: source))!
-            modules[key] = (module, function)
-        }
+        let (module, function) = makeKernel(source, extraOptions: [
+            .defineMacro("KERNEL", as: String(describing: source)),
+            .defineMacro("TYPE", as: T.kernelDataType.rawValue),
+            .defineMacro("OP(_x_, _y_)", as: operation.source)
+        ])
+        modules[key] = (module, function)
         return function
     }
 

    }

    /// Cached (compiled and loaded) modules
    fileprivate var modules: [ModuleCacheKey : (Module, Function)] = Dictionary(minimumCapacity: 32)

    /// Initialize an instance on device
    ///

        return manager
    }

    /// Current CUDA device
    let device: Device

    /// Unique hash key for each module
