Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ИНСАЙД ИНФА MPI.pdf
Скачиваний:
15
Добавлен:
15.04.2015
Размер:
3.3 Mб
Скачать

1

2

3

4

5

6

7

8

9

10

11

12

456

CHAPTER 14. PROFILING INTERFACE

int extent;

 

int result

= PMPI_Send(buffer,count,datatype,dest,tag,comm);

MPI_Type_size(datatype, &extent); /* Compute size */ totalBytes += count*extent;

totalTime += MPI_Wtime() - tstart;

/* and time

*/

return result;

}

13

14.4.2 MPI Library Implementation

 

14

15On a Unix system, in which the MPI library is implemented in C, then there are various

16possible options, of which two of the most obvious are presented here. Which is better

17depends on whether the linker and compiler support weak symbols.

18

19 Systems with Weak Symbols

20

If the compiler and linker support weak external symbols (e.g. Solaris 2.x, other system

 

21

V.4 machines), then only a single library is required through the use of #pragma weak thus

 

22

 

23

#pragma weak MPI_Example = PMPI_Example

 

24

 

25

int PMPI_Example(/* appropriate args */)

 

26

{

 

27

/* Useful content */

 

28

}

 

29

 

30The e ect of this #pragma is to de ne the external symbol MPI_Example as a weak

31de nition. This means that the linker will not complain if there is another de nition of the

32symbol (for instance in the pro ling library), however if no other de nition exists, then the

33linker will use the weak de nition.

34

35

Systems Without Weak Symbols

 

36

 

37In the absence of weak symbols then one possible solution would be to use the C macro

38pre-processor thus

39

40

41

42

43

44

45

46

47

48

#ifdef PROFILELIB

#ifdef __STDC__

#define FUNCTION(name) P##name

#else

#define FUNCTION(name) P/**/name

#endif

#else

# define FUNCTION(name) name #endif