add mail_ping_irq example
This commit is contained in:
parent
c2341562c7
commit
f3c241d1fe
2 changed files with 73 additions and 11 deletions
|
@ -210,7 +210,7 @@ int icc_halt(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define ROUNDS 100000
|
||||
#define ROUNDS 10000
|
||||
|
||||
int icc_mail_ping( void )
|
||||
{
|
||||
|
@ -271,6 +271,61 @@ int icc_mail_ping( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int icc_mail_ping_irq( void )
|
||||
{
|
||||
/* return if not core 0 */
|
||||
if( my_ue ) return;
|
||||
|
||||
uint32_t flags;
|
||||
uint64_t timer;
|
||||
int rem_rank = (my_ue+1)%2;
|
||||
int i;
|
||||
iRCCE_MAIL_HEADER* recv_header = NULL;
|
||||
|
||||
kprintf( "Hello from mail_ping ... \n" );
|
||||
|
||||
// disable interrupts
|
||||
flags = irq_nested_disable();
|
||||
|
||||
for( i=0; i<ROUNDS+1; ++i ) {
|
||||
if( my_ue == 0 ) {
|
||||
/* send ping request */
|
||||
iRCCE_mail_send(0, PING_REQ, 0, NULL, rem_rank);
|
||||
|
||||
|
||||
/* send interrupt */
|
||||
icc_send_irq(rem_rank);
|
||||
|
||||
/* wait for response */
|
||||
do {
|
||||
iRCCE_mail_recv(&recv_header);
|
||||
} while( !recv_header );
|
||||
|
||||
/* release mail */
|
||||
iRCCE_mail_release(&recv_header);
|
||||
}
|
||||
|
||||
/* start timer in first round */
|
||||
if( i == 0 ) timer = rdtsc();
|
||||
|
||||
}
|
||||
|
||||
/* stop timer */
|
||||
timer = rdtsc() - timer;
|
||||
|
||||
|
||||
kprintf( "timer = %d\n", timer );
|
||||
if( my_ue == 0 ) {
|
||||
kprintf( "mail_pingpong needs in average %f µsec (%d ticks)!\n",
|
||||
timer/(2.0*ROUNDS*533), timer/(2*ROUNDS) );
|
||||
}
|
||||
|
||||
irq_nested_enable(flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icc_mail_check(void)
|
||||
{
|
||||
iRCCE_MAIL_HEADER* header = NULL;
|
||||
|
@ -279,18 +334,24 @@ void icc_mail_check(void)
|
|||
|
||||
// empty mailbox and interpret headers
|
||||
while( (res = iRCCE_mail_recv( &header )) == iRCCE_SUCCESS ) {
|
||||
if( header->tag == 1 ) {
|
||||
iRCCE_mail_send( 0, 2, 0, NULL, header->source );
|
||||
}
|
||||
else if( header->tag == iRCCE_ANYLENGTH ) {
|
||||
switch( header->tag ) {
|
||||
case iRCCE_ANYLENGTH:
|
||||
recv_buffer = (char*)kmalloc( header->size );
|
||||
iRCCE_irecv( recv_buffer, header->size, header->source, NULL );
|
||||
iRCCE_mail_send( 0, 2, 0, NULL, header->source );
|
||||
}
|
||||
else if( header->tag == iRCCE_ANYLENGTH_PIGGYBACK ) {
|
||||
iRCCE_mail_send( 0, 2, 0, NULL, header->source );
|
||||
iRCCE_irecv(recv_buffer, header->size,
|
||||
header->source, NULL );
|
||||
iRCCE_mail_send(0, 2, 0, NULL, header->source);
|
||||
break;
|
||||
|
||||
case iRCCE_ANYLENGTH_PIGGYBACK:
|
||||
iRCCE_mail_send(0, 2, 0, NULL, header->source);
|
||||
break;
|
||||
|
||||
case PING_REQ:
|
||||
iRCCE_mail_send(0, PING_RESP, 0, NULL, header->source);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
iRCCE_mail_release( &header );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ static int STDCALL foo(void* arg)
|
|||
|
||||
#ifdef CONFIG_ROCKCREEK
|
||||
int STDCALL mail_ping(void* arg) {
|
||||
icc_mail_ping();
|
||||
// icc_mail_ping();
|
||||
icc_mail_ping_irq();
|
||||
icc_halt();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue