Skip to content

GPU compatibility

Gabriele Bozzola edited this page Nov 20, 2023 · 8 revisions

Do not use Ref in broadcasted expressions

If you are using Ref to pass a constant to all the broadcasted calls, use a keyword argument instead.

Instead of:

func1(a, b) = a * b

A = [1, 2, 3]
B = 2

result = func1.(A, Ref(B))
func2(a; b) = a * b

A = [1, 2, 3]
B = 2

result = func2.(A; b = B)

Do not use Symbols in broadcasted expressions

Do make isbits structs

When you define a new struct that doesn't contain ClimaCore objects, check that isbits(A) is true, where A is a typical instance of your struct.

Clone this wiki locally