Exemple #1
0
void CValueObject_Ctor(CValueObject* pMe)
{
    DECLARE_PVTBL(pvt, IValueObject);

    CBase_Ctor((CBase*)pMe);

    VT_FUNC(pvt, CValueObject, Release);
    VT_FUNC(pvt, CValueObject, SetValue);
    VT_FUNC(pvt, CValueObject, GetValue);
}
Exemple #2
0
void CEventDispatcher_Ctor(CEventDispatcher* pMe)
{
    DECLARE_PVTBL(pvt, IEventDispatcher);

    CBase_Ctor(&pMe->base);

    pMe->m_pListeners = CVector_New();
    IVector_SetPfnFree(pMe->m_pListeners, FREE);

    VT_FUNC(pvt, CEventDispatcher, Release);
    VT_FUNC(pvt, CEventDispatcher, AddListener);
    VT_FUNC(pvt, CEventDispatcher, RemoveListener);
    VT_FUNC(pvt, CEventDispatcher, Notify);
}
Exemple #3
0
// *******************************************************************************************
// init the matrix
// executed once per tile; inits the tile-core and its borders (halo-region)
int matrix_init::execute( const loop_tag & tag, my_context & c ) const
{
#ifdef CNC_WITH_ITAC
    VT_FUNC( "init" );
#endif
    const int NX = tag.x < c.BNX - 1 ? BSIZEX : c.BBSX;
    const int NY = tag.y < c.BNY - 1 ? BSIZEY : c.BBSY;
    const int NZ = tag.z < c.BNZ - 1 ? BSIZEZ : c.BBSZ;
    const int Nx = c.Nx + 2*HSIZE;
    const int Ny = c.Ny + 2*HSIZE;
    const int Nz = c.Nz + 2*HSIZE;

    std::shared_ptr< tile_type > tile( new tile_type );

    for (int z = 0; z < NZ+2*HSIZE; ++z) {
        for (int y = 0; y < NY+2*HSIZE; ++y) {
            for (int x = 0; x < NX+2*HSIZE; ++x) {
                /* set initial values */

                float r = fabs((float)( x + tag.x*BSIZEX - Nx/2 + y + tag.y*BSIZEY - Ny/2 + z + tag.z*BSIZEZ - Nz/2) / 30);
                r = std::max(1 - r, 0.0f) + 1;
                assert( r != 0.0f );
                (*tile)(x-HSIZE,y-HSIZE,z-HSIZE) = r;
            }
        }
    }
    c.m_tiles.put( tag, std::shared_ptr< const tile_type >( tile ) );
    return 0;
}
        bool GenericCommunicator::RecvThread::recv_msg( int & sender )
        {
            VT_FUNC( "Dist::GenComm::recv_msg" );
            // ==> Wait for a client to send a message:

            // ==> Receive the message from a client:
            try {
                serializer * ser = m_channel.waitForAnyClient( sender );
                
                // Check:
                CNC_ASSERT( 0 <= sender && sender < m_channel.numProcs() );
                CNC_ASSERT( sender != m_channel.localId() );
                
                if( ser ) {
                    // Ok, there is body to it, that's why we got the serializer
                    // Call the recv callback of the communicator instance
                    m_instance.recv_msg_callback( *ser, sender );
                    return false;
                } else {
                    // ==> termination requested !!!
                    return true;
                }
            }
            catch ( ConnectionError ) {
                CNC_ABORT( "Connection Error" );
            }
            catch ( ... ) {
                //throw ClientId( sender );
            }
            return false;
        }
        void GenericCommunicator::recv_msg_callback( serializer & ser, int sender )
        {
            // ITAC logging:
            VT_RECV( sender, (int)ser.get_total_size(), ITC_TAG_EXTERNAL );

            // Prepare the serializer for unpacking:
            //BufferAccess::initUnpack( ser );

            // Delegate the message to the distributor:
            /*            int globalSenderId = sender + m_globalIdShift; uncomment this for the local tests */
            {
                VT_FUNC( "Dist::distributor::recv_msg" );
                distributor::recv_msg( &ser/*, globalSenderId uncomment this for the local tests */ );
            }
        }
Exemple #6
0
// *******************************************************************************************
// this is the actual stencil computation
// executed once per tile and time-step
int stencil_step::execute( const loop_tag & tag, my_context & c ) const
{
#ifdef CNC_WITH_ITAC
    VT_FUNC( "RTM::stencil" );
#endif
    const int NX = tag.x < c.BNX - 1 ? BSIZEX : c.BBSX;
    const int NY = tag.y < c.BNY - 1 ? BSIZEY : c.BBSY;
    const int NZ = tag.z < c.BNZ - 1 ? BSIZEZ : c.BBSZ;

    halo_tile htile;
    htile.get_tile_and_halo( tag, c.BNX, c.BNY, c.BNZ, NX, NY, NZ,
                             c.m_tiles, c.m_xhalos, c.m_yhalos, c.m_zhalos );
              

    float c0 = c.coeff_x[0], c1 = c.coeff_x[1], c2 = c.coeff_x[2], c3 = c.coeff_x[3], c4 = c.coeff_x[4];

#ifndef VBSZZ
# define VBSZZ BSIZEZ
#endif
 
    CnC::parallel_for( 0, NZ, (const int)VBSZZ, [=]( int bz ) {
            for( int z = bz; z < NZ && z < bz+VBSZZ; ++z ) {
                for( int y = 0; y < NY; ++y ) {
                    STENCIL_KERNEL( htile, 0, NX, y, z );
                }
            }
      }, CnC::pfor_tuner< false >() );

#ifdef DAMPING
    CnC::parallel_for( 0, NZ, (const int)VBSZZ, [=,&c]( int bz ) {
            int dampx_beg = 0;
            int dampx_end = NX;
            int dampy_beg = 0;
            int dampy_end = NY;
            
            int _start = tag.x * BSIZEX;
            if( _start < DSIZE ) {
                dampx_beg = _start + NX >= DSIZE ? DSIZE : NX;
                for( int z = bz; z < NZ && z < bz+VBSZZ; ++z ) {
                    for( int y = 0; y < NY; ++y ) {
                        STENCIL_KERNEL( htile, 0, dampx_beg, y, z );
                    }
                }
            }
            int _damp = c.Nx - DSIZE;
            if( _start + NX > _damp ) {
                dampx_end = _start < _damp ? _damp - _start : 0;
                for( int z = bz; z < NZ && z < bz+VBSZZ; ++z ) {
                    for( int y = 0; y < NY; ++y ) {
                        STENCIL_KERNEL( htile, dampx_end, NX, y, z );
                    }
                }
            }

            _start = tag.y * BSIZEY;
            if( _start < DSIZE ) {
                dampy_beg = _start + NY >= DSIZE ? DSIZE : NY;
                for( int z = bz; z < NZ && z < bz+VBSZZ; ++z ) {
                    for( int y = 0; y < dampy_beg; ++y ) {
                        STENCIL_KERNEL( htile, dampx_beg, dampx_end, y, z );
                    }
                }
            }
            _damp = c.Ny - DSIZE;
            if( _start + NY > _damp ) {
                dampy_end = _start < _damp ? _damp - _start : 0;
                for( int z = bz; z < NZ && z < bz+VBSZZ; ++z ) {
                    for( int y = dampy_end; y < NY; ++y ) {
                        STENCIL_KERNEL( htile, dampx_beg, dampx_end, y, z );
                    }
                }
            }

            _start = bz + tag.z * BSIZEZ;
            if( _start < DSIZE ) {
                int dampz_beg = _start + NZ >= DSIZE ? DSIZE : NZ;
                for( int z = bz; z < dampz_beg && z < bz+VBSZZ; ++z ) {
                    for( int y = dampy_beg; y < dampy_end; ++y ) {
                        STENCIL_KERNEL( htile, dampx_beg, dampx_end, y, z );
                    }
                }
            }
            _damp = c.Nz - DSIZE;
            if( _start + VBSZZ > _damp ) {
                int dampz_beg = _start < _damp ? _damp - _start : 0;
                int dampz_end = _start + VBSZZ >= NX ? NX : _start + VBSZZ;
                for( int z = dampz_beg; z < dampz_end; ++z ) {
                    for( int y = dampy_beg; y < dampy_end; ++y ) {
                        STENCIL_KERNEL( htile, dampx_beg, dampx_end, y, z );
                    }
                }
            }
      }, CnC::pfor_tuner< false >() );
#endif // DAMPING

    htile.put_tile_and_halo( tag, c.BNX, c.BNY, c.BNZ, c.T, NX, NY, NZ,
                             c.m_tiles, c.m_xhalos, c.m_yhalos, c.m_zhalos );

    // now let's put the next tag (if not at end of time)
    int t1 = tag.t + 1;
	if( t1 < c.T ) {
		c.m_tags.put( loop_tag( t1, tag.x, tag.y, tag.z ) );
	}
    return 0;
}