Created
June 23, 2025 12:35
-
-
Save Alexander-Barth/adcffa5074ae44b803523ab2fedddf54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using CUDA | |
| @inline function _division(::Type{T},factor,exponent) where T | |
| TIME_DIVISION = ( | |
| (:day, 24*60*60, 0), | |
| (:hour, 60*60, 0), | |
| (:minute, 60, 0), | |
| (:second, 1, 0), | |
| (:millisecond, 1, -3), | |
| (:microsecond, 1, -6), | |
| (:nanosecond, 1, -9), | |
| ) | |
| ntuple(length(TIME_DIVISION)) do i | |
| (T(10)^(-exponent) * TIME_DIVISION[i][2]) ÷ | |
| (T(10)^(-TIME_DIVISION[i][3]) * factor) | |
| end | |
| end | |
| function foo(dt) | |
| factor,exponent = (86400,0) | |
| divi = _division(Int64,factor,exponent) | |
| return divi[1] * dt | |
| end | |
| dt_cpu = [1,2,3] | |
| dt_gpu = cu(dt_cpu) | |
| a_d = foo.(dt_gpu) # fine | |
| CUDA.synchronize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment