API Reference

Complete reference for the Parallax runtime API

Overview

The Parallax runtime provides a simple C API for GPU-accelerated computing. The API is designed to be minimal and easy to integrate into existing C++ applications.

Header: #include <parallax/runtime.h>
Library: -lparallax-runtime

Core Functions

Memory Management

C parallax/runtime.h
void* parallax_umalloc(size_t size, unsigned flags);
void parallax_ufree(void* ptr);

parallax_umalloc - Allocate unified memory accessible from both CPU and GPU

  • size: Size in bytes to allocate
  • flags: Reserved for future use (pass 0)
  • Returns: Pointer to allocated memory, or NULL on failure

parallax_ufree - Free unified memory

  • ptr: Pointer previously returned by parallax_umalloc
Automatic Coherence: Memory allocated with parallax_umalloc uses software-defined unified memory with block-level dirty tracking. Coherence is maintained automatically - no explicit synchronization needed!

Example Usage

C++ example.cpp
#include <iostream>
#include <vector>
#include <algorithm>
#include <execution>

int main() {
    std::vector<float> data(1'000'000, 1.0f);
    
    // GPU acceleration - automatic memory coherence
    std::for_each(std::execution::par,
                  data.begin(), data.end(),
                  [](float& x) { x *= 2.0f; });
    
    // Use results immediately - no sync needed!
    std::cout << "Result: " << data[0] << std::endl;
    
    return 0;
}

See Also