Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On older GPU there are no hcos/hsin/hlog/hexp #887

Merged
merged 3 commits into from
Dec 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dfdx-core/src/tensor_ops/utilities/compatibility.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,12 @@ __device__ __forceinline__ double atomicMinf(double * addr, double value) {
} else {
return __longlong_as_double(atomicMin((long long int *)addr, __double_as_longlong(value)));
}
}
}

#if __CUDA_ARCH__ < 530
//On older GPU there are no hcos/hsin/hlog/hexp.
__device__ __forceinline__ __half hcos(__half a) { return __float2half(cosf(__half2float(a))); }
__device__ __forceinline__ __half hsin(__half a) { return __float2half(sinf(__half2float(a))); }
__device__ __forceinline__ __half hlog(__half a) { return __float2half(logf(__half2float(a))); }
__device__ __forceinline__ __half hexp(__half a) { return __float2half(expf(__half2float(a))); }
#endif
Loading