Mxnet Source Read 6

Source: Internet
Author: User
Tags mxnet

mxnet/src/storage/storage.cc

Mxnet/include/mxnet/storage.h

Mxnet/include/mxnet/base.h

The above three files collectively describe the storage virtual class and the results of its instantiation, where storage.h defines the storage abstract interface (virtual function) Alloc free directfree and the static method get, It defines the handle handle that will be used to manipulate and manage memory later, which consists of two parts that describe the properties of the memory itself, including the address void *dptr and size size_t, and the context CTX describing the device where the memory resides; Where the context structure is defined in Base.h, its members have two dev_type (1-cpu 2-gpu 3-cpu_pinned) and the other is dev_id, while in base there are some related functions that build context, such as the GPU (...). CPU (...) cpupinned (,,,) fromstring (...) and so on can directly build the related equipment environment.

Storageimpl is Stroage's specific inheritance class interface has the return handle Alloc function free function and directfree function, while the static function activatedevice to switch the GPU device, the CPU device actually does not switch, So the realization is just a direct break.

From the implementation of ALLOC, its application of memory includes CPU memory, cpupinned memory and GPU memory pool, there is no simple interface to request a single GPU memory.

Also summarize the files and classes in the Mxnet/src/storage directory:

Cpu_device_storage.h gpu_device_storage.h Pinned_memory_storage.h builds the classes that are responsible for CPU GPU and cpupinned memory requests respectively.

Storage_manager.h is purely an abstract interface class. Naive_storage_manager.h and Pooled_storage_manager.h are abstract classes Storage_manager are concrete implementations. In essence, the CPU (including cpupinned) and the GPU (memory pool) are managed by C + + polymorphism.

The contents of the entire storage directory in the Mxnet framework belong to the underlying module python and other interfaces that do not involve the interface.

In summary, it provides a memory request and a release interface with the handle of the Handle operation, i.e. Handle Alloc (size_t size, Context ctx), void free (Handle Handle), void The Directfree (Handle Handle) function unifies the CPU GPU interface. CPU and cpupinned are ready to apply free mode at any time, GPU memory in memory pool mode.

Guess Gpu_device_storage.h is for the future application of temporary resources.

Mxnet Source Read 6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.