Beispiel #1
0
bool CHeap1::CreateFromBuffer( void* buffer, uint size ) {
	pHeapMemoryStart = buffer;
	void *_start = (void*) ALIGNUP( (uint)buffer, AlignMent );
	void *_end = (void*) ALIGNDOWN( (uint)buffer + size, AlignMent );
	pHeapEnd = _end;

	pSentinel = (Node*)_start;
	Node* new_node = (Node*)_start + 1;

	pSentinel->pPrevMem = NULL;
	pSentinel->pNextMem = new_node;
	pSentinel->pPrevFree = NULL;
	pSentinel->pNextFree = new_node;

	new_node->pPrevMem = pSentinel;
	new_node->pNextMem = (Node*)_end;
	new_node->pPrevFree = pSentinel;
	new_node->pNextFree = NULL;
}
Beispiel #2
0
void ADIOI_Calc_file_domains(ADIO_Offset *st_offsets, ADIO_Offset
                             *end_offsets, int nprocs, int nprocs_for_coll,
                             ADIO_Offset *min_st_offset_ptr,
                             ADIO_Offset **fd_start_ptr, ADIO_Offset
                             **fd_end_ptr, ADIO_Offset *fd_size_ptr)
{
    /* Divide the I/O workload among "nprocs_for_coll" processes. This is
       done by (logically) dividing the file into file domains (FDs); each
       process may directly access only its own file domain. */

    ADIO_Offset min_st_offset, max_end_offset, *fd_start, *fd_end, fd_size;
    ADIO_Offset alignment = *fd_size_ptr;
    int i;

#ifdef AGG_DEBUG
    FPRINTF(stderr, "ADIOI_Calc_file_domains: %d aggregator(s)\n",
            nprocs_for_coll);
#endif

    /* find min of start offsets and max of end offsets of all processes */

    min_st_offset = st_offsets[0];
    max_end_offset = end_offsets[0];

    for (i=1; i<nprocs; i++) {
        min_st_offset = ADIOI_MIN(min_st_offset, st_offsets[i]);
        max_end_offset = ADIOI_MAX(max_end_offset, end_offsets[i]);
    }

    /* determine the "file domain (FD)" of each process, i.e., the portion of
       the file that will be "owned" by each process */

    /* partition the total file access range equally among nprocs_for_coll
       processes */

    if (alignment) {
        min_st_offset = ALIGNDOWN(min_st_offset, alignment);
        fd_size = ((max_end_offset - min_st_offset + 1)
                   + nprocs_for_coll - 1)/nprocs_for_coll;
        fd_size = (fd_size + alignment -1 ) / alignment * alignment;
    } else {
        fd_size = ((max_end_offset - min_st_offset + 1) + nprocs_for_coll -
                   1)/nprocs_for_coll;
    }

    /* ceiling division as in HPF block distribution */

    *fd_start_ptr = (ADIO_Offset *)
                    ADIOI_Malloc(nprocs_for_coll*sizeof(ADIO_Offset));
    *fd_end_ptr = (ADIO_Offset *)
                  ADIOI_Malloc(nprocs_for_coll*sizeof(ADIO_Offset));

    fd_start = *fd_start_ptr;
    fd_end = *fd_end_ptr;

    fd_start[0] = min_st_offset;
    fd_end[0] = min_st_offset + fd_size - 1;

    for (i=1; i<nprocs_for_coll; i++) {
        fd_start[i] = fd_end[i-1] + 1;
        fd_end[i] = fd_start[i] + fd_size - 1;
    }

    /* take care of cases in which the total file access range is not
       divisible by the number of processes. In such cases, the last
       process, or the last few processes, may have unequal load (even 0).
       For example, a range of 97 divided among 16 processes.
       Note that the division is ceiling division. */

    for (i=0; i<nprocs_for_coll; i++) {
        if (fd_start[i] > max_end_offset)
            fd_start[i] = fd_end[i] = -1;
        if (fd_end[i] > max_end_offset)
            fd_end[i] = max_end_offset;
    }

    *fd_size_ptr = fd_size;
    *min_st_offset_ptr = min_st_offset;
}