Documentation

Hesper.Async

Asynchronous GPU Operations #

Provides async GPU compute using Lean 4's Task system.

Features #

Usage Example #

-- Launch async compute
let task ← asyncCompute shader inputBuffers

-- Do other work...
doOtherWork

-- Wait for result
let result ← task.get

Result of an async GPU operation

  • value : α

    The computed result

  • executionTimeMs : Float

    Execution time in milliseconds

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[reducible, inline]

      Async GPU compute task

      Equations
      Instances For
        def Hesper.Async.launchAsync {α : Type} [Inhabited α] (computation : IO (AsyncResult α)) :

        Helper to launch async task

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Launch async shader execution and return a Task

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Launch async buffer read and return a Task

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Launch async buffer write and return a Task

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Hesper.Async.parallel {α : Type} (tasks : Array (IO (AsyncTask α))) :

                Execute multiple GPU tasks in parallel

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Hesper.Async.awaitAll {α : Type} (tasks : Array (AsyncTask α)) :

                  Wait for all tasks to complete

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Hesper.Async.mapTask {α β : Type} (f : αβ) (task : AsyncTask α) :

                    Map a function over an async task result

                    Equations
                    Instances For
                      def Hesper.Async.bindTask {α β : Type} (task : AsyncTask α) (f : αIO (AsyncTask β)) :

                      Bind two async tasks sequentially

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Pipeline multiple async GPU operations

                        Instances For

                          Create a pipeline from a single async operation

                          Equations
                          Instances For
                            def Hesper.Async.AsyncPipeline.andThen {α β : Type} [Inhabited α] [Inhabited β] (p1 : AsyncPipeline α) (f : αIO (AsyncTask β)) :

                            Chain two pipeline stages

                            Equations
                            Instances For
                              def Hesper.Async.AsyncPipeline.map {α β : Type} (f : αβ) (p : AsyncPipeline α) :

                              Map over pipeline result

                              Equations
                              Instances For

                                Execute the pipeline and wait for result

                                Equations
                                Instances For

                                  Async compute configuration

                                  • shader : String

                                    Shader source code

                                  • workgroups : Nat × Nat × Nat

                                    Workgroup dimensions

                                  • inputSizes : Array Nat

                                    Input buffer sizes

                                  • outputSize : Nat

                                    Output buffer size

                                  Instances For
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      Launch async compute operation

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

                                        Batch async operations

                                        • operations : Array (IO (AsyncTask α))

                                          Operations to execute

                                        • maxConcurrency : Nat

                                          Maximum concurrent tasks

                                        Instances For

                                          Execute operations in batches with concurrency limit

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Priority for async tasks (currently just documentation in Lean 4)

                                            Instances For
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For