GithubHelp home page GithubHelp logo

Comments (7)

tlively avatar tlively commented on July 17, 2024

is non-default memory supposed to be accessible from languages like C at all?

No, not without a language extension to add some notion of new address spaces with incompatible pointers. It's possible that we will have such language extensions in clang in the future, but probably not soon.

Other existing languages are in similar situations, although brand new languages could try to account for the possibility of having multiple memories in their core design.

is this feature mainly for offline tools which rewrite instructions?

Exactly. Multi-memory will be useful for code instrumentation and for merging multiple modules into one.

from multi-memory.

penzn avatar penzn commented on July 17, 2024

is non-default memory supposed to be accessible from languages like C at all?
as memory index is encoded as an immediate, it doesn't seem straightforward to implement "far" pointers which can access those memories.

There are languages that supports address spaces, OpenCL for example, and they should be able to handle memory indices without fat pointers.

from multi-memory.

yamt avatar yamt commented on July 17, 2024

is non-default memory supposed to be accessible from languages like C at all?

No, not without a language extension to add some notion of new address spaces with incompatible pointers. It's possible that we will have such language extensions in clang in the future, but probably not soon.

Other existing languages are in similar situations, although brand new languages could try to account for the possibility of having multiple memories in their core design.

is this feature mainly for offline tools which rewrite instructions?

Exactly. Multi-memory will be useful for code instrumentation and for merging multiple modules into one.

ok. thank you for explanation.

from multi-memory.

yamt avatar yamt commented on July 17, 2024

is non-default memory supposed to be accessible from languages like C at all?
as memory index is encoded as an immediate, it doesn't seem straightforward to implement "far" pointers which can access those memories.

There are languages that supports address spaces, OpenCL for example, and they should be able to handle memory indices without fat pointers.

interesting.
do you mean this stuff? https://en.wikipedia.org/wiki/OpenCL#Memory_hierarchy

from multi-memory.

ratchetfreak avatar ratchetfreak commented on July 17, 2024

The best option so far would be the fancy pointers in C++ allocators (which was supposed to be to support near/far) wasm::ptr<T, uint memidx=0> however you will need to create specific specializations for nearly everything because most of the std lib assumes that those can be converted to a raw dereferenceable pointer which is the entire issue with the index being an immediate of the instruction.

Unless you implement the deref of a "far" pointer when multiple memories are present through a switch. Same with all other memory ops taking that memory index as an immediate. And then you are hoping that the compiler and/or the implementation can inline and constant fold the memory index and pick the correct intrinsic.

from multi-memory.

penzn avatar penzn commented on July 17, 2024

Sorry, I missed the notification somehow.

do you mean this stuff? https://en.wikipedia.org/wiki/OpenCL#Memory_hierarchy

Yes, that is what I meant. LLVM supports this via addrspace annotation which works similarly to memindex in this proposal: 0 is the default, and there are no assigned meaning to other ones. It should be possible to lower those annotations to mulit-memory. OpenCL doesn't have to be the source language, especially given what it is meant to be used for, it just has a very similar model built into it.

fancy pointers in C++ allocators (which was supposed to be to support near/far) wasm::ptr<T, uint memidx=0>

This actually sounds like a good option. The problem, as pointed out, is referencing locations across memories. It is a useful feature, as it would eliminate duplicating code for the sake of targeting a different memory. OpenCL also considered that and has 'generic' (address space agnostic) pointer since version 2.0.

Filed #32 for cross-memory references.

from multi-memory.

rossberg avatar rossberg commented on July 17, 2024

Closing this as answered.

from multi-memory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.