MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / cprefetch

Function cprefetch

csrc/pythonInterface.cpp:565–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565void cprefetch(void* ptr, size_t bytes, int device) {
566
567 int hasPrefetch = 0;
568 CUDA_CHECK_RETURN(
569 cudaDeviceGetAttribute(&hasPrefetch, cudaDevAttrConcurrentManagedAccess, device)
570 ); // 40ns overhead
571 if (hasPrefetch == 0)
572 return;
573
574#if CUDART_VERSION >= 13000
575 cudaMemLocation loc{};
576 loc.type = cudaMemLocationTypeDevice;
577 loc.id = device;
578 CUDA_CHECK_RETURN(cudaMemPrefetchAsync(ptr, bytes, loc, 0u, 0));
579#else
580 CUDA_CHECK_RETURN(cudaMemPrefetchAsync(ptr, bytes, device, 0));
581#endif
582
583 CUDA_CHECK_RETURN(cudaPeekAtLastError());
584}
585
586#define CMAKE_ELEMENTWISE_FUNC(fname, type_name, ctype, FUNC) \
587 void c##fname##_##type_name(ctype* A, ctype* B, ctype value, long n) { fname##_##type_name(A, B, value, n); }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected