add some performance counters and remove bug in the physical to virtual address translation
This commit is contained in:
parent
5472960a13
commit
af6ef23085
3 changed files with 42 additions and 11 deletions
|
@ -85,6 +85,8 @@ static inline void svm_flush(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
int svm_statistics(void);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -48,6 +48,9 @@ static volatile uint8_t* page_owner = NULL;
|
|||
static size_t phys2virt[SHARED_PAGES] = {[0 ... SHARED_PAGES-1] = 0};
|
||||
static size_t shmbegin = 0;
|
||||
static int my_ue = 0;
|
||||
static uint32_t emit[RCCE_MAXNP] = {[0 ... RCCE_MAXNP-1] = 0};
|
||||
static uint32_t request[RCCE_MAXNP] = {[0 ... RCCE_MAXNP-1] = 0};
|
||||
static uint32_t forward[RCCE_MAXNP] = {[0 ... RCCE_MAXNP-1] = 0};
|
||||
|
||||
int svm_init(void)
|
||||
{
|
||||
|
@ -119,6 +122,7 @@ int svm_access_request(size_t addr)
|
|||
/* send ping request */
|
||||
iRCCE_mail_send(2*sizeof(size_t), ICC_TAG_SVMREQUEST, 0, payload, remote_rank);
|
||||
|
||||
request[remote_rank]++;
|
||||
NOP8;
|
||||
icc_send_irq(remote_rank);
|
||||
|
||||
|
@ -134,8 +138,7 @@ int svm_access_request(size_t addr)
|
|||
|
||||
void* svmmalloc(size_t size)
|
||||
{
|
||||
size_t phyaddr;
|
||||
size_t viraddr;
|
||||
size_t phyaddr, viraddr, i;
|
||||
uint32_t flags;
|
||||
uint32_t map_flags = MAP_KERNEL_SPACE|MAP_MPE|MAP_SVM;
|
||||
|
||||
|
@ -158,7 +161,8 @@ void* svmmalloc(size_t size)
|
|||
}
|
||||
|
||||
viraddr = map_region(0, phyaddr, size >> PAGE_SHIFT, map_flags);
|
||||
phys2virt[(phyaddr - shmbegin) >> PAGE_SHIFT] = viraddr;
|
||||
for(i=0; i<size; i+=PAGE_SIZE)
|
||||
phys2virt[(phyaddr + i - shmbegin) >> PAGE_SHIFT] = viraddr + i;
|
||||
|
||||
kprintf("svmmalloc: phyaddr 0x%x, viraddr 0x%x, size 0x%x\n", phyaddr, viraddr, size);
|
||||
|
||||
|
@ -167,7 +171,7 @@ void* svmmalloc(size_t size)
|
|||
|
||||
void svmfree(void* addr, size_t size)
|
||||
{
|
||||
size_t phyaddr;
|
||||
size_t phyaddr, i;
|
||||
uint32_t flags;
|
||||
|
||||
if (BUILTIN_EXPECT(!addr || !size, 0))
|
||||
|
@ -181,7 +185,8 @@ void svmfree(void* addr, size_t size)
|
|||
kprintf("svmfree: phyaddr 0x%x, viraddr 0x%x, size 0x%x\n", phyaddr, addr, size);
|
||||
|
||||
unmap_region((size_t) addr, size >> PAGE_SHIFT);
|
||||
phys2virt[(phyaddr - shmbegin) >> PAGE_SHIFT] = 0;
|
||||
for(i=0; i<size; i+=PAGE_SIZE)
|
||||
phys2virt[(phyaddr + i - shmbegin) >> PAGE_SHIFT] = 0;
|
||||
|
||||
// iRCCE is not thread save => disable interrupts
|
||||
flags = irq_nested_disable();
|
||||
|
@ -219,8 +224,10 @@ int svm_emit_page(size_t phyaddr, int ue)
|
|||
/* send ping request */
|
||||
iRCCE_mail_send(2*sizeof(size_t), ICC_TAG_SVMREQUEST, 0, payload, remote_rank);
|
||||
|
||||
NOP8;
|
||||
NOP8;
|
||||
icc_send_irq(remote_rank);
|
||||
|
||||
forward[remote_rank]++;
|
||||
} else {
|
||||
size_t viraddr = phys2virt[(phyaddr - shmbegin) >> PAGE_SHIFT];
|
||||
|
||||
|
@ -230,9 +237,29 @@ int svm_emit_page(size_t phyaddr, int ue)
|
|||
page_owner[pageid] = ue;
|
||||
// need to write to another line to make sure the write combine buffer gets flushed
|
||||
*(int *)RCCE_fool_write_combine_buffer = 1;
|
||||
|
||||
emit[ue]++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int svm_statistics(void)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
kprintf("emit\t:");
|
||||
for(i=0; i<RCCE_MAXNP; i++)
|
||||
kprintf("\t%u", emit[i]);
|
||||
kprintf("\nrequest\t:");
|
||||
for(i=0; i<RCCE_MAXNP; i++)
|
||||
kprintf("\t%u", request[i]);
|
||||
kprintf("\nforward\t:");
|
||||
for(i=0; i<RCCE_MAXNP; i++)
|
||||
kprintf("\t%u", forward[i]);
|
||||
kputs("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -131,7 +131,7 @@ static int svm_test(void *arg)
|
|||
my_ue = RCCE_ue();
|
||||
num_ues = RCCE_num_ues();
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
if (!my_ue) {
|
||||
// allocate and initialize SVM region
|
||||
A[0] = (int*) kmalloc(3*N*N*sizeof(int));
|
||||
|
@ -192,15 +192,15 @@ static int svm_test(void *arg)
|
|||
|
||||
svm_flush();
|
||||
|
||||
// Now, we need only read access on A and B
|
||||
change_page_permissions((size_t) A[0], (size_t) (A[0]+2*N*N), VMA_CACHEABLE|VMA_READ);
|
||||
RCCE_barrier(&RCCE_COMM_WORLD);
|
||||
|
||||
kputs("Start parallel calculation...\n");
|
||||
|
||||
start = rdtsc();
|
||||
start = rdtsc();
|
||||
|
||||
// Now, we need only read access on A and B
|
||||
change_page_permissions((size_t) A[0], (size_t) (A[0]+2*N*N), VMA_CACHEABLE|VMA_READ);
|
||||
RCCE_barrier(&RCCE_COMM_WORLD);
|
||||
|
||||
// start calculation
|
||||
for(i=my_ue*(N/num_ues); i<(my_ue+1)*(N/num_ues); i++)
|
||||
for(j=0; j<N; j++)
|
||||
|
@ -233,6 +233,8 @@ static int svm_test(void *arg)
|
|||
|
||||
svmfree((void*) A[0], 3*N*sizeof(int));
|
||||
|
||||
svm_statistics();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue