EcologicalNetworks.jl icon indicating copy to clipboard operation
EcologicalNetworks.jl copied to clipboard

GPU compatability

Open gottacatchenall opened this issue 4 years ago • 6 comments
trafficstars

As part of MetacommunityDynamics.jl, we want to be able to use EN.jl types and generative models on GPUs.

Here's a running list of my understanding of the changes required to use EN.jl with DynamicGrids.jl on a GPU:

  • [ ] Non-mutable structs for (Unipartite/Bipartite) networks. This could be done via a wrapper around UnipartiteNetwork and BipartiteNetwork (e.g. GPUUnipartiteNetwork)

gottacatchenall avatar Jun 30 '21 12:06 gottacatchenall

A few points of clarification. A wrapper wouldn't be sufficient, as none of the contents can be mutable either. The object needs to be isbits(obj) = true. What could work is e.g. a StaticUnipartideNetwork built on StaticArrays.jl and modified with Accessors.jl.

Additionally, this is required to work with DynamicGrids.jl even on CPU.

rafaqz avatar Jun 30 '21 12:06 rafaqz

Additionally, this is required to work with DynamicGrids.jl even on CPU.

This is only in the case that you want to use a UnipartiteNetwork/BipartiteNetwork as a custom grid-element, correct? This may be the case for some applications but not all

gottacatchenall avatar Jun 30 '21 12:06 gottacatchenall

Yep as the content of a grid on CPU, and as any part of a model on GPU. I don't really know how this package works :)

rafaqz avatar Jun 30 '21 12:06 rafaqz

It's also possible to use immutable structs for the networks and swap the Vectors for CuArray, if the networks are just fields in a rule.

rafaqz avatar Jun 30 '21 13:06 rafaqz

So... the types used to be immutable (but not the content of the fields), and it was a lot more trouble for many, many applications. But this is clearly something I'd like to have at some point. I'm happy to discuss more.

tpoisot avatar Jul 23 '21 00:07 tpoisot

I think a possible solution here would be wrapper types which via macro could convert as-existing EN.jl network types to immutable supertype of each EN.jl type (e.g. GPUUnipartiteNetwork, etc) prior to deploying on GPU

gottacatchenall avatar Aug 17 '21 21:08 gottacatchenall