exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
15.06k stars 520 forks source link

Sample code for GPU could not work on M1 Mac #104

Closed learningpro closed 1 year ago

learningpro commented 1 year ago

When codon run the sample code for GPU, it shows:

libdevice.10.bc: error: Could not open input file: No such file or directory

How to fix this?

import gpu

MAX    = 1000  # maximum Mandelbrot iterations
N      = 4096  # width and height of image
pixels = [0 for _ in range(N * N)]

def scale(x, a, b):
    return a + (x/N)*(b - a)

@gpu.kernel
def mandelbrot(pixels):
    idx = (gpu.block.x * gpu.block.dim.x) + gpu.thread.x
    i, j = divmod(idx, N)
    c = complex(scale(j, -2.00, 0.47), scale(i, -1.12, 1.12))
    z = 0j
    iteration = 0

    while abs(z) <= 2 and iteration < MAX:
        z = z**2 + c
        iteration += 1

    pixels[idx] = int(255 * iteration/MAX)

mandelbrot(pixels, grid=(N*N)//1024, block=1024)
arshajii commented 1 year ago

Currently the gpu module only supports Nvidia GPUs, but we are planning to add support for M1 soon.

learningpro commented 1 year ago

Glad to here that, thanks and waiting for the support

0x3333 commented 1 year ago

Is there somewhere we can follow the M1 support for GPU? Or the announcements only?