Comments (4)
first of all, to be sure that we are on the same page, note that @CellType
and the celldims
key word of the allocator functions rely on the package CellArrays which defines the type CellArray
.
CellArray
creates the StaticArray cells on the fly when accessed. Mutable StaticArrays cannot be created in GPU kernels as they would require heap allocation (besides, performance would certainly be terrible in this use case). Thus, only immutable types are used. Nevertheless, CellArray
s' content is mutable. The following example shows three ways of content mutation (the example does not use ParallelStencil, but the same applies also in this case):
using CellArrays, StaticArrays
function main_CellArrays()
nel = 2
celldims = (3, 3)
Cell = SMatrix{celldims..., Float64, prod(celldims)}
C = CPUCellArray{Cell}(undef, nel)
C.data .= 0.0
# The aims is to change te values of each 3x3 matrix
# 1 - with a double loop for each element: it works
for e=1:nel
for i=1:celldims[1]
for j=1:celldims[2]
field(C,i,j)[e] = 1.0
end
end
end
@show C
# 2 - assigning cell by cell
for e=1:nel
C[e] = Cell(ones(celldims))
end
@show C
# 3 - assiging all data at once
C.data .= 9.0
@show C
end
main_CellArrays()
Check out the documentation of CellArrays for more information.
Also, it would be nice to have the CellType act as the tensor it is meant to represent, while still only storing the needed values. For example, defining @CellType SymmetricTensor2D fieldnames=(xx, zz, xz) I could then overload getindex
(...)
I think i think it should work to create an alternative indexing on top of the indexing created by @CellType. If you can work something out that is robust and performance, then we would be happy for a pull request in CellArrays.jl for this additional functionality on top of the existing functionality.
from parallelstencil.jl.
Thanks, I understand much better how CellArrays
is meant to work now.
I find too often I try to reinvent the wheel. When in doubt, someone smarter in Julia than I has thought of these things.
For my purposes, storing the state vector of my system of equations in a StructArray
from StructArrays.jl
with elements of type Tensor
from Tensorial.jl
has all of the functionality I want, and the storage and access efficiency has been optimized behind the scenes.
from parallelstencil.jl.
@TakeTwiceDailey: StructArray
from StructArrays.jl
performs very badly on GPU (and I also ran into some errors on GPU). This is actually the very reason why I created the package CellArrays
(I had first experimented with StructArray
s and did some performance tests on GPU). If you only want to run on CPU, then both performance and functionality of StructArray
should be good.
from parallelstencil.jl.
@omlins Oh, I see.
I would certainly like to run on a GPU at some point, but I have many problems to surmount before what I want to do is working on the CPU.
If I were to run this on the GPU, we would not only need to make CellArrays
act like tensors, we would need to make @einsum
work properly on them as well. I'm afraid I am not a software developer in any sense, so a lot of this machinery is way over my head.
from parallelstencil.jl.
Related Issues (20)
- AMDGPU v0.5.0 compat HOT 1
- Add device_sync
- sync issues on AMDGPU backend
- finite volume method HOT 3
- [JuliaCon/proceedings-review] @parallel keyword argument `loopopt` deprecated? HOT 1
- ParallelStencil on 1.10 HOT 6
- [JuliaCon/proceedings-review] DOI of paper by Besard et al. HOT 2
- [JuliaCon/proceedings-review] Community guidelines HOT 1
- [JuliaCon/proceedings-review] Performance metrics HOT 4
- Type unstable Data.Number HOT 2
- GPU memory management issue when running multi-GPU code HOT 10
- Add support for Polyester's `@batch` HOT 20
- Generalize loopopt
- Create and update GPU unit tests
- Thread (CPU) Float32/Float64 performance comparison on miniapp acoustic2D HOT 12
- Example for init_global_grid_usage HOT 3
- How to implement custom finite differencing operators HOT 8
- CUDA Crash with julia 1.9.0 HOT 8
- Non cartesian gather! HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parallelstencil.jl.