Skip to content

GPU compatibility

Gabriele Bozzola edited this page Nov 29, 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 not use abstract types in structs.

Do not use Function is struct definition

Use F <: Function instead.

Define 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.

Use SVectors or Tuples instead of Vectors

Obtain FT from state or parameters