-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The snrt_memset function in alloc.h:
snitch_cluster/sw/snRuntime/src/alloc.h
Lines 98 to 103 in 1b9da15
| // TODO colluca: optimize by using DMA | |
| inline void *snrt_memset(void *ptr, int value, size_t num) { | |
| for (uint32_t i = 0; i < num; ++i) | |
| *((uint8_t *)ptr + i) = (unsigned char)value; | |
| return ptr; | |
| } |
And the snrt_dma_memset function in dma.h are to some extent redundant:
snitch_cluster/sw/snRuntime/src/dma.h
Lines 389 to 408 in 1b9da15
| /** | |
| * @brief Fast memset function performed by DMA. | |
| * @param ptr Pointer to the start of the region. | |
| * @param value Value to set. | |
| * @param len Number of bytes, must be a multiple of the DMA bus width. | |
| */ | |
| inline void snrt_dma_memset(void *ptr, uint8_t value, uint32_t len) { | |
| // set first 64bytes to value | |
| // memset(ptr, value, 64); | |
| uint8_t *p = ptr; | |
| uint32_t nbytes = 64; | |
| while (nbytes--) { | |
| *p++ = value; | |
| } | |
| // DMA copy the the rest | |
| snrt_dma_txid_t memset_txid = | |
| snrt_dma_start_2d(ptr, ptr, 64, 64, 0, len / 64); | |
| snrt_dma_wait_all(); | |
| } |
Merge them and also handle specific case of a memset to zero by taking advantage of the cluster's zero memory. See the following as an example:
snitch_cluster/sw/snRuntime/src/start.c
Lines 40 to 41 in 1b9da15
| snrt_dma_start_1d((void*)(tls_ptr + i * tls_offset), | |
| (void*)(snrt_zero_memory_ptr()), size); |
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request