Template Class memory_t#
Defined in File memory.cuh
Nested Relationships#
Nested Types#
Class Documentation#
-
template<class params>
class memory_t# The memory class (YP: \(\mu_{m}\)).
Public Types
-
typedef arith_env_t<params> arith_t#
The arithmetical environment used by the arbitrary length integer library.
Public Functions
- inline __host__ __forceinline__ memory_t (arith_t arith, memory_data_t *content)
The constructor of the memory class given the memory data structure.
- Parameters
arith – [in] The arithmetical environment.
content – [in] The memory data structure.
- inline __host__ __device__ __forceinline__ memory_t (arith_t arith)
The constructor of the memory class given the arithmetical environment.
- Parameters
arith[in] – The arithmetical environment.
- inline __host__ __device__ __forceinline__ ~memory_t ()
The destructor of the memory class. Frees the allcoated data and the memory data structure.
- inline __host__ __device__ __forceinline__ size_t size ()
The size of the memory. (Last offset reached by the memory access) x 32 (YP: \(32 \dot \mu_{i}\))
- Returns
The size of the memory.
- inline __host__ __device__ __forceinline__ void allocate_pages (size_t new_size, uint32_t &error_code)
Allocates pages for the given offset if needed.
- Parameters
new_size – [in] The new size of the memory.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ void grow_cost (bn_t &index, bn_t &length, bn_t &gas_used, uint32_t &error_code)
The memory cost of the memory. (YP: \(C_{mem}-M(\mu_{i}, index, length)\))
- Parameters
index – [in] The index of the memory access.
length – [in] The length of the memory access.
gas_used – [out] The gas cost after.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ size_t get_last_offset (bn_t &index, bn_t &length, uint32_t &error_code)
Get the highest offset of the memory access.
- Parameters
index – [in] The index of the memory access.
length – [in] The length of the memory access.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ void grow (bn_t &index, bn_t &length, uint32_t &error_code)
Increase the memory for the given offset if needed. Offset is computed from the index and the length.
- Parameters
index – [in] The index of the memory access.
length – [in] The length of the memory access.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ uint8_t * get (bn_t &index, bn_t &length, uint32_t &error_code)
Get the a pointer to the given memory data.
- Parameters
index – [in] The index of the memory access.
length – [in] The length of the memory access.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ void set (uint8_t *data, bn_t &index, bn_t &length, size_t &available_size, uint32_t &error_code)
Set the given memory data.
- Parameters
data – [in] The data to be set.
index – [in] The index of the memory access.
length – [in] The length of the memory access.
error_code – [out] The error code.
- inline __host__ __device__ __forceinline__ void to_memory_data_t (memory_data_t &dst)
Copy the current memory data to the given memory data structure.
- Parameters
dst – [out] The destination memory data structure.
- inline __host__ __device__ void print ()
Print the memory data structure.
- inline __host__ cJSON * json ()
Get the memory data structure as a JSON object.
- Returns
The JSON object.
Public Members
-
memory_data_t *_content#
The memory data structure
Public Static Functions
- static inline __host__ memory_data_t * get_cpu_instances (uint32_t count)
Allocate the CPU memory data structures for the given number of instances.
- Parameters
count – [in] The number of instances.
- Returns
The CPU memory data structures.
- static inline __host__ void free_cpu_instances (memory_data_t *instances, uint32_t count)
Free the CPU memory data structures for the given number of instances.
- Parameters
instances – [in] The CPU memory data structures.
count – [in] The number of instances.
- static inline __host__ memory_data_t * get_gpu_instances_from_cpu_instances (memory_data_t *cpu_instances, uint32_t count)
Allocate the GPU memory data structures for the given number of instances.
- Parameters
cpu_instances – [in] The CPU memory data structures.
count – [in] The number of instances.
- Returns
The GPU memory data structures.
- static inline __host__ void free_gpu_instances (memory_data_t *gpu_instances, uint32_t count)
Free the GPU memory data structures for the given number of instances.
- Parameters
gpu_instances – [in] The GPU memory data structures.
count – [in] The number of instances.
- static inline __host__ memory_data_t * get_cpu_instances_from_gpu_instances (memory_data_t *gpu_instances, uint32_t count)
Copy the GPU memory data structures to the CPU memory data structures.
- Parameters
gpu_instances – [in] The GPU memory data structures.
count – [in] The number of instances.
- Returns
The CPU memory data structures.
- static inline __host__ __device__ __forceinline__ void print_memory_data_t (arith_t &arith, memory_data_t &memory_data)
Print the memory data structure.
- Parameters
arith – [in] The arithmetical environment.
memory_data – [in] The memory data structure.
- static inline __host__ cJSON * json_from_memory_data_t (arith_t &arith, memory_data_t &memory_data)
-
struct memory_data_t#
The memory data structure.
Public Members
-
size_t size#
The size of the memory acceesed by now (YP: \(32 \dot \mu_{i}\))
-
size_t allocated_size#
Internal allocated size do not confuse with size
-
evm_word_t memory_cost#
The memory cost (YP: \(M(\mu_{i})\))
-
uint8_t *data#
The data of the memory
-
size_t size#
-
typedef arith_env_t<params> arith_t#