Patrick Ribeiro
email: patrick.ribeiro@u-paris10.fr

Lavinia Diogo Queiros-Condé

Laurent Grosu

Gallimard
email: lgallima@u-paris10.fr

Diogo Queiros-Condé
email: dqueiros-conde@u-paris10.fr

Lavinia Grosu
email: lavinia.grosu@u-paris10.fr

Laurent Gallimard

An exergetic approach for materials fatigue

Keywords: fatigue, exergy, entropy, plastic deformation quality, fracture

An entropy approach has been recently developed, based on the irreversible thermodynamics and entropy production. It has been observed that, for low cycle fatigue, metals undergoing cyclic load reach fracture, at a certain level of entropy production called fracture fatigue entropy (FFE) (Naderi and Khonsari, 2010), solely dependent on the material. Until now, we only used the two principles of thermodynamics separately to follow the behaviour of a solid continuum problem as low cycle fatigue. We propose here to use the two laws of thermodynamics together via the Gouy-Stodola equation and the concept of exergy to provide a new description for metals undergoing low cycle fatigue.

Introduction

Predicting the remaining life and the failure of a system is a society issue. Indeed, mechanical fatigue is responsible for many accidents like the tragic accident of Savigny-sur-Orge (France) in 2013 with the fatigue fracture of a splint implying the derailment of a train. Consequently, the field of fatigue mechanics is a domain of major interest for the research community.

Since the pioneering work of Whöler, many studies have been done to predict the number of cycles that a material can hold to failure. On cumulative damage [START_REF] Miner | Cumulative damage in fatigue[END_REF][START_REF] Coffin | A note on low cycle fatigue laws[END_REF][START_REF] Manson | Interpretive report on cumulative fatigue damage in the low cycle range[END_REF], empirical laws on low cycle fatigue [START_REF] Morrow | Cyclic plastic strain energy and fatigue of metals[END_REF][START_REF] Halford | The energy required for fatigue[END_REF], on energy dissipation and strain energies of deformation [START_REF] Park | Evaluation of an energy based approach and a critical plane approach for predicting constant amplitude multiaxial fatigue life[END_REF] and on the bond between temperature, thermodynamics and fatigue [START_REF] Lemaitre | Damage measurements[END_REF][START_REF] Lemaitre | Mechanics of Solid Materials[END_REF][START_REF] Fargione | Rapid determination of the fatigue curve by the thermographic method[END_REF][START_REF] Meneghetti | Analysis of the fatigue strength of a stainless steel based on the energy dissipation[END_REF].

The second law and more precisely, entropy, is through all its forms (Clausius entropy, Boltzmann entropy, Gibbs-Shannon entropy) well known and used in multiple domains. Thus, regarding the plastic deformation, and entropy through irreversible thermodynamics leads to a natural framework for studying fatigue. It has been shown that metals in low cycle fatigue possess a constant fracture fatigue entropy (FFE), solely dependent on the material [START_REF] Khonsari | Introduction to Thermodynamics of Mechanical Fatigue[END_REF]. This FFE represents the maximum accumulative entropy of the system. It is dependent on thermodynamic fluxes and forces involved in the process and informs us about the point of failure of a system.

In mechanical fatigue, the concepts of energy and entropy are used through the first and second principles. Exergy which can be expressed combining these two laws, represents the available energy, i.e., the mechanised fraction of the energy [START_REF] Gouy | Sur l'énergie utilisable[END_REF][START_REF] Stodola | Die Dampfturbinen und die Aussichten der Wärmekraftmaschinen[END_REF][START_REF] Keenan | Availability and irreversibility in thermodynamics[END_REF][START_REF] Rant | Exergie, ein neues wort fur technische arbeitsfahigkeit[END_REF]. It defines the quality of an energy taking into account its environment and is used in the domain of engineering [START_REF] Grosu | Exergie et systèmes énergétiques: Transition vers l'exergétique[END_REF][START_REF] Grosu | Study of the improvement in the performance coefficient of machines operating with three reservoirs[END_REF][START_REF] Feidt | Optimal use of energy systems and processes[END_REF][START_REF] Pishbin | Experimental study on the effects of flame regime on the exergy destruction in premixed low swirl combustion[END_REF] or natural resources [START_REF] Valero Delgado | Exergy Evolution of the Mineral Capital on Earth[END_REF][START_REF] Hoque | Exergy analysis of construction material manufacturing processes and assessment of their improvement potentials[END_REF] where the use of this physical quantity is leading the way to a sustainable development through economy [START_REF] Tsatsaronis | Recent developments in exergy analysis and exergoeconomics[END_REF] and is spreading increasingly to other domains [START_REF] Talla Konchou | An application of energy and exergy analysis at the transportation sector of Cameroon[END_REF][START_REF] Sorgüven | First and second law work production efficiency of a muscle cell[END_REF].

Order, disorder, thermodynamic entropy, multi-scale and fractal fatigue conduct to the question about if we consider the material dislocations being piloted by a fractal structure and its energetic events, What is the fractal representation of this energy flow (and its complementary)? and Where are the fractal support and its location? The field of fractals in materials is well documented [START_REF] Carpinteri | Fractal nature of material microstructure and size effects on apparent mechanical properties[END_REF][START_REF] Hähner | Fractal dislocation patterning during plastic deformation[END_REF] and the reflections about fractal geometry [START_REF] Mandelbrot | Les objets fractals : forme, hasard et dimension[END_REF][START_REF] Méhauté | Flèche du temps et géométrie fractale[END_REF], entropy minimisation and constructal theory [START_REF] Bejan | Advanced Engineering Thermodynamics[END_REF][START_REF] Wechsatol | Tree-shaped flow structures: are both thermalresistance and flow-resistance minimisations necessary?[END_REF] and geometrical structure of entropy generation [START_REF] Queiros-Condé | A diffusion equation to describe scale-and time-dependent dimensions of turbulent interfaces[END_REF]Queiros-Condé et al., 2015a, 2015b;[START_REF] Canivet | Fractal representation of exergy[END_REF] lead us to the exergy equation for a better understanding of mechanical fatigue.

In this paper, we present the new concept of exergy for low cycle fatigue pursuing the work on FFE of [START_REF] Khonsari | Introduction to Thermodynamics of Mechanical Fatigue[END_REF] and papers related to the FFE (Naderi et al., 2010;[START_REF] Amiri | On the role of entropy generation in processes involving fatigue[END_REF]Naderi and Khonsari, 2010), in order to highlight new considerations in mechanical fatigue and plastic deformation using the idea of quality with exergy.

Two thermodynamic principles for fatigue in materials

The analysis is based on the two laws of thermodynamics applied to a sample during a fatigue test. The first principle of thermodynamics (conservation of energy) can be written by:

ρ u = -div Q + σ : D, ( 1
)
where ρ is the density of the material, Q is the surface heat flux exchanged through the boundaries, D the rate of deformation tensor (strain tensor per unit time), and σ the stress tensor.

The second law adds the notion of inequality between heat and other types of energies like mechanical work. Moreover, irreversibility is highlighted through entropy, as a measure of disorder (more precisely level of micro-states):

ρ ṡ = -div ( Q T ) + π, ( 2
)
where ṡ is the specific entropy variation per unit time and -div

( Q T )
the specific entropy flow due to heat transfer (external entropy)

The specific entropy production rate π (internal entropy) characterises irreversible transformations (real transformations), thus, this term is always superior or equal to zero. It comes simply:

ρ ṡ + div Q T - ( Q T 2 • ∇T ) ≥ 0. (3)
And using equation (1) in equation (3):

ρ ṡ + σ : D -ρ u T - ( Q T 2 • ∇T ) ≥ 0. ( 4
)
Now the Helmholtz free energy ψ is introduced. It is a thermodynamic potential for the useful work obtainable by a closed system at temperature T :

ψ = u -T s. ( 5
)
The derivative with respect to time allows to obtain the expression of the entropy as a function of free energy:

ṡ - u T = -1 T ( ψ + s Ṫ ) . ( 6
)
And using equation (6) in equation ( 4) leads to:

-ρ T [( ψ + s Ṫ )] + σ : D T Mechanical term - ( Q T 2 • ∇T ) Thermal term ≥ 0. (7)
This equation shows two sources of deviation of a reversible phenomenon, a mechanical part and a thermal part. In the mechanical part, the elastic component does not have an impact on the entropy production as it is a reversible phenomenon.

Assuming the fact that the system is submitted to small deformations, the linearisation of the deformation rate tensor into a total strain rate which is decomposed into plastic and elastic strain rate become possible:

D = ε = εp + εe . ( 8
)
The free energy rate can be written using the chain rule as a function of multiple variables [START_REF] Lemaitre | Mechanics of Solid Materials[END_REF]:

ψ = dψ dϵ e • εe + dψ dT • Ṫ + dψ dV k • Vk (9)
V k : Set of internal variables related to internal phenomena at lower scales. Finally, replacing equations ( 8) and (9) in equation ( 7):

    ( σ -ρ dψ dϵ e ) : εe T     + [ σ : εp T ] + [ -ρ Ṫ T ( s + dψ dT ) ] + [ -ρ T ( dψ dV k Vk )] + ( - Q T 2 • ∇T ) ≥ 0. (10)
Thanks to the work of [START_REF] Lemaitre | Mechanics of Solid Materials[END_REF], this equation can be simplified using particular transformations:

• An elastic-reversible transformation without changes in internal variables and at constant and uniform temperature

σ = ρ dψ dϵ e . ( 11
)
• An elastic homogeneous transformation without changes in internal variables and at a uniform temperature.

s = - dψ dT . ( 12
)
These relations, considered as state laws, attest for reversible transformations and do not contribute to generating entropy (with respect to the small strain hypothesis in equation ( 8)).

To simplify equations, the thermodynamic force A k related to the thermodynamic flux Vk is defined:

A k = ρ dψ dV k . ( 13
)
Using equations ( 10)-( 13), the equation of entropy production for materials fatigue can be retrieved:

π = σ : εp T + ( - A k Vk T ) + ( - Q T 2 • ∇T ) > 0 (14)
σ : εp T : Entropy generation associated with mechanical power dissipated into plastic deformation.

-

A k Vk T : Entropy generation associated with unrecoverable power stored in the material.

-

Q T 2
• ∇T : Entropy generation associated to heat flux. The mechanical and thermodynamical approaches are different. For mechanical scientists, elastic transformations are reversible. In the point of view of thermodynamics, elastic transformations are real implying entropy production, and irreversibility (represented by the internal variables in this equation).

The simplest case to study is low cycle fatigue for metals, which implies the second and third term in equation ( 14) to be neglected [START_REF] Lemaitre | Mechanics of Solid Materials[END_REF]Naderi et al., 2010):

A k Vk T << σ : εp T Q T 2 • ∇T << σ : εp T . ( 15
)
The entropy production reduces in this case to: The FFE is the accumulative maximum entropy that a material can hold, i.e., when the material reaches, its FFE, it breaks: The use of the Helmholtz free energy permits to link the two principles (equations ( 1) and ( 5)) [START_REF] Lemaitre | Mechanics of Solid Materials[END_REF]:

π = σ : εp T > 0 (
FFE = ∫ t f 0 ( σ : εp T ) dt = N f W cp T (17)
ρ ( ψ + T ṡ + s Ṫ ) = σ : D -div Q. ( 18
)
Then using equations ( 9), ( 11)-( 13) and using the small deformation hypothesis in equation ( 8) the expression becomes:

A k Vk + ρT ṡ = σ : εp -div Q. ( 19
)
In addition, entropy can be expressed by:

s = -dψ dT , thus ṡ = -d 2 ψ dT dt . ( 20
)
Then using equations ( 9) and ( 11)-( 13) ṡ becomes:

ṡ = -1 ρ dσ dT : εe + ds dT Ṫ - 1 ρ dA k dT Vk . ( 21
)
Now replacing ṡ in equation ( 19), the following equation is obtained:

ρC Ṫ = σ : εp -div Q -A k Vk + T ( dσ dT : εe + dA k dT Vk ) . ( 22
)
With C, the specific heat:

C = T ds dT = -T d 2 ψ dT 2 .
This equation shows the dependence of the temperature variation from classic macroscopic and internal variables. Furthermore, there are new thermo-coupled terms. The thermoelasticity phenomenon (reversible) and a thermo-coupled term related to internal variation (irreversible). This thermo-coupled term related to internal variation is an irreversible phenomenon that can be added to the thermoelastic phenomenon since an elastic deformation is not really reversible thermodynamically. This equation could be used for thermal fatigue dealing with thermal constraints.

Comparing the classical first principle used previously (equation ( 1)) and the equation obtained (equation ( 22)) leads to the equality:

σ : εe = -A k Vk + T ( dσ dT : εe + dA k dT . Vk ) (23)
Indicating the direct transformation of elastic deformation into internal and thermo-coupled variables and leading to the entropy production:

π = σ : D T - ( dσ dT : εe + dA k dT Vk ) - ( Q T 2 • ∇T ) . ( 24
)
It is interesting to note that, assuming a steady-state during the fatigue test and using the two basic principles (equations ( 1) and ( 2)) leads to the same result (neglecting the thermocoupled terms), without the need of introducing the Helmholtz free energy. The disadvantage of this method is that the Helmholtz free energy is a linear combination of the two principles and is temperature dependent, whereas, the concept of exergy uses a constant environment temperature.

Exergy is defined as the maximum useful work obtainable from a system in contact with the environment or can be considered as a distance from equilibrium. Exergy analysis of the fatigue is applicable to every system submitted to mechanical and repetitive constraints.

The fatigue exergy can be expressed as a simple linear combination of the first and second principle (considering the work of the ambient pressure on the material negligible):

ρ ẋ = ρ ( u -T 0 ṡ) . ( 25
)
And replacing in equation ( 25), the internal energy variation and entropy variation from equations ( 1) and ( 2), the following equation is deduced:

ρ ẋ = -div Q + σ : D + T 0 div ( Q T ) -T 0 π ẋd , ( 26
)
where represents the exergy destruction flow. This quantity symbolises the generation of irreversibility, a deflection of the transformation from the reversibility. Using the entropy generation π (equation ( 14)), exergy balance becomes:

ρ ẋ = -div Q ( 1 - T 0 T ) ẋq + σ : εp ( 1 - T 0 T ) ẋp + σ : εe ẋe - ( - T 0 T A k Vk ) ȧn k ( 27
)
ẋe : Specific exergy flow associated to elastic deformation.

ẋq : Specific exergy flow associated to heat transfer.

ẋp : Specific exergy flow associated to plastic deformation ȧn k : Specific energy flow associated to internal variables.

The equation obtained shows that the energy of plastic deformation, has a lower quality than the pure mechanical work. Its exergy corresponds to the second term of the exergy balance, it is an energy multiplied by the Carnot factor. Then, an interesting term is found associated with internal variables, which is pure energy. The dependence of the plastic deformation on temperature is evident through exergy analysis. The exergy related to plastic deformation can be interpreted as a quality of deformation, indeed, higher temperature implies more effective deformation and thus less material lifetime. For example, [START_REF] Hong | The effect of temperature on low-cycle fatigue behavior of prior cold worked 316l stainless steel[END_REF], using experiments on a stainless steel 316L, for a constant plastic strain energy density varying the temperatures of the tests, obtains that the fatigue life at higher temperatures is smaller than the fatigue life at lower temperatures. In other words, for a same quantity of work, exergy deformation will be higher for a superior temperature and imply a better quality of deformation. If a machine could receive the energy accumulated during the fatigue of the material, it would get more energy (exergy) from a material's fatigue fracture at a higher temperature than a material's fracture at lower temperature.

The elastic deformation is viewed as pure mechanical work and so a 'noble' energy that confirms the mechanical definition of an elastic transformation (reversible). In fact, deformation, in general, is not reversible, consequently, to be in accordance with continuum mechanics the internal variables take into account these small scales phenomena and allows to be in agreement with very high cycle fatigue. Indeed, for solicitations under the yield strength, the deformation is quasi-elastic since plasticity appears at small scales. Internal damping, phase transition, dislocations ... are phenomena included in the internal variables. Above the yield strength, hardening appears and can be expressed with hardening variables R ṗ and X : εp cumulative plastic deformation and centre of displacement [START_REF] Lemaitre | Mechanics of Solid Materials[END_REF]. In terms of exergy balance, the pure irreversibility produced by the quasielastic transformation is related to the internal variables energy, which can be translated as a pure impossibility to produce work.

The exergy balance has the advantage to be a fraction of the energy, easier to represent and to use than entropy and entropy production. The Carnot factor represents precisely the coefficient of quality and imply the use of only a fraction of energy. The differences between energies are perceptible thanks to this approach ie the different energies are not directly added like the energy balance does, but their corresponding exergies are. For instance, the work of elastic deformation is fully recoverable whereas for heat and plastic deformation, only a part is recoverable. Since heat and plastic deformation have the same behaviour, we can illustrate plastic exergy as the maximum plastic work obtainable from a Carnot's machine operating between the environment and a plastic deformation source at temperature T (see Figure 1). Another asset of using exergy comes from the fact that exergy destruction appears avoidable. Indeed, exergy destruction manifests itself through energy, thus, the control of temperature leads to the control of the degree of irreversibility. However, the limits of this control come from phase transitions and new material behaviours at higher temperatures integrated into internal variables. Another interesting expression is obtained using equations ( 26) and ( 24). It expresses the exergy with general deformation and thermo-coupled variables:

ρ ẋ = -div Q ( 1 - T 0 T ) + σ : D ( 1 - T 0 T ) + T 0 ( dσ dT : εe + dA k dT Vk ) . ( 28
)
Here, we can see that the irreversibility comes from thermo-coupled-internal exergy destruction (last term in the equation) and that the deformation in a general definition (elastic and plastic) possesses a quality, plus a thermoelastic component, which seems to be a pure exergy, or a 'noble' energy.

The numerical applications are based on the experiments of Naderi et al. (2010), [START_REF] Amiri | On the role of entropy generation in processes involving fatigue[END_REF], Naderi and Khonsari (2010) for the Al-6061 T6 and the SS 304 in low cycle fatigue regime and with a solicitation ratio R = -1 (no mean stress). Materials and their properties are presented in Table 1.

Table 1 Fatigue properties of the Al-6061 T6 and the SS 304 The temperature profiles and the number of cycles to failure are taken from the four tests done by Naderi and Khonsari (2010). Furthermore, the reference temperature will be taken equal to T 0 = 288 K. It represents the ambient temperature and can be set as the reference to compare multiple systems with an exergy balance. It permits to obtain the profile of the Carnot factor during the test. For the elastic and the plastic deformation, the Park & Nelson's law permits a good evaluation of the work of each part [START_REF] Park | Evaluation of an energy based approach and a critical plane approach for predicting constant amplitude multiaxial fatigue life[END_REF] in order to calculate exergy, using the number of cycles to fracture N f :

σ ′ f [M P a] ε ′ f b c E [GP a] ν Al-6061
σ : ϵ p = AN α f σ : ϵ e = BN β f (29) A = 2 2+b+c σ ′ f ϵ ′ f ( c -b c + b ) B = 2 2b+1 (1 + ν)(σ ′ f ) 2 3E α = b + c β = 2b.
To simplify, we can hypothesise that the temperature is constant over the whole range of the test to calculate a constant Carnot factor θ (the two phases corresponding to the rise of temperature at the beginning and the end of the fatigue life represents very few cycles). We present in Table 2 experimental results and properties from the tests in Naderi et al. (2010), [START_REF] Amiri | On the role of entropy generation in processes involving fatigue[END_REF] and Naderi and Khonsari (2010). Furthermore, using the loading frequency and replacing the Park & Nelson model permits to obtain the plastic exergy, the exergy destruction (superscripts c for cyclic and superscript T for total) and the volumetric entropy production flow:

x d T = ∫ N f 0 x d c = ∫ N f 0 T 0 T AN α f = T 0 T AN α+1 f (30) x p T = ∫ N f 0 x p c = ∫ N f 0 ( 1 - T 0 T ) AN α f = ( 1 - T 0 T ) AN α+1 f (31) θ = 1 - T 0 T π = f AN α f T ẋd = f x d c ẋp = f x p c ( 32
)
The results of the different tests of the Carnot factor, volumetric entropy production flow, plastic exergy and exergy destruction fluxes are presented in Figure 2 for the Al-6061 T6 and Figure 3 for the SS 304. Fracture fatigue entropy, total exergy destruction and total plastic exergy dissipated over the whole life of the material are presented in Tables 3 and4. Some particular and interesting characteristics emerge from the results. The first concerns the FFE, which appears quasi-constant for low cycle fatigue for both materials. Likewise, total exergy destruction and the total plastic exergy seems constant, with a little perk, more stability about the constancy of these parameters. We can then observe for both materials submitted to bending fatigue that a decrease in displacement amplitude (deformation work) imply a decrease in the Carnot factor, entropy production flow, plastic exergy and exergy destruction. Since an ideal reversible transformation involve a null entropy production flux, lowering the displacement amplitude for bending fatigue implies a transformation closer to the ideal transformation which is traduced by less exergy destruction and less plastic exergy bringing logically to a higher fatigue life of the material (assuming the constancy of both total exergies such as the FFE), in other words, permitting to endure more cycles until the maximum accumulative entropy, the FFE (or the maximum accumulative exergy plastic or destruction). However, for torsion fatigue, the preceding interpretation is not verified.

N f 1 = 2833 T1 = 311 K N f a = 13, 000 Ta = 673 K N f 2 = 5000 T2 = 306 K N f b = 16, 000 T b = 533 K N f 3 = 8500 T3 = 303 K N f 3 = 9450 T3 = 415 K N f 4 = 14, 000 T4 = 301 K N f 4 = 14, 150 T4
Besides the Carnot factor and the plastic exergy decrease, it is observed an increase in entropy production flux and in exergy destruction when the material is submitted to lower displacement amplitude (higher fatigue life). This comes from a greater importance of the Carnot factor in front of the plastic work in the entropy production flow compared to the bending fatigue (where the Carnot factor slightly changes compared to the plastic work). Furthermore, at high temperature, the material behaviour becomes more and more viscous which can lead to small strain hypothesis incompatibility and Park and Nelson incorrect estimation of the plastic work deformation (recalling that in the torsion cases T /T melting equals 0.4 (a) and 0.32 (b)). Nevertheless, a property between the different materials and type of fatigue is shared, it is the increase of the number of cycles to fracture when the plastic exergy diminishes, ie, when the quality of the plastic deformation declines implying the bond between the quality of deformation and fatigue life. Based on thermodynamics analysis of low cycle fatigue [START_REF] Khonsari | Introduction to Thermodynamics of Mechanical Fatigue[END_REF], and the notion of FFE which seems to only depend on the material, it has been demonstrated through the Gouy-Stodola equation (the exergy balance) that plastic deformation can be considered as a 'degraded energy' like the classical heat energy. This plastic exergy is a measure of the quality of the plastic deformation and consequently, measures the dependence of the material life on the temperature and its environment through the Carnot factor (quality factor). The energy quality (exergy) increases with the Carnot factor, but the interpretation for plastic deformation is different from heat energy. As the exergy of heat, the exergy of plastic work deformation corresponds to the maximum efficient use for plastic deformation. But, the more efficient the energy of deformation, the less the material lifetime. In the specific case of low cycle fatigue, the plastic work deformation is the principal source of irreversibility. High and very high cycle fatigue display the two other sources of irreversibility: internal variables and heat. The very high cycle fatigue uses stress below the yield strength, involving pure reversible elastic transformations and leading, from a theoretical mechanical point of view to an infinite life of the material. However, from a thermodynamical approach, very high cycle fatigue is a succession of elastic transformations, accompanied by an entropy generation and implies a finite life of the material. Thus, according to thermodynamical considerations, the fatigue limit (corresponding to a fatigue limit stress where below, the material, in theory, would have an infinite life) doesn't seem to exist (for example, [START_REF] Bathias | How and why the fatigue S-N curve does not approach a horizontal asymptote[END_REF], Wang et al. (1999aWang et al. ( , 1999b) ) and [START_REF] Zuo | Effect of microstructure on ultra-high cycle fatigue behavior of Ti-6Al-4V[END_REF]), strengthening the idea of a thermodynamical framework for fatigue. Exergy, dealing with the study of a system with its environment could be very useful for fatigue (highly sensitive on environmental conditions) in the characterisation of a material's lifetime, furthermore, the quality of an elastic transformation and the energy-related to internal variables can lead to a new perspective in high and very cycle fatigue.

Nomenclature

  16) σ : εp represents the work of plastic deformation per unit time which can be approximated by empirical laws like Coffin-Manson, Morrow or Park & Nelson's law.

  t f : Time to failure. N f : Number of cycles to failure. W cp : Cyclic Work of plastic deformation per unit volume. Naderi et al. (2010) have demonstrated for Al-6061 T6 and SS 304 that their FFE was a property of the material, independent of any other parameter.

Figure 1

 1 Figure 1 Carnot's machine analogy of heat for the plastic deformation (see online version for colours)

Figure 2

 2 Figure 2 Results for the Al-6061 T6 (see online version for colours)

Figure 3

 3 Figure 3 Results for the SS 304 (see online version for colours)

Table 2

 2 Properties of the tests done byNaderi et al. (2010) for the Al-6061 T6 fatigue andNaderi and Khonsari (2010) for the SS 304 both at f =10 Hz

		Al-6061 T6			SS 304
			Displacement			Displacement
	Test	Type	amplitude	Test	Type	amplitude
	T est 1	Bending	δ1 = 49.53 mm	T est a	Torsion	δa = 35.56 mm
	T est 2		δ2 = 48.26 mm	T est b		δ b = 33.02 mm
	T est 3		δ3 = 38.1 mm	T est 3	Bending	δ3 = 49.53 mm
	T est 4		δ4 = 35.56 mm	T est 4		δ4 = 45.72 mm
		Cycles to failure	Temperature	Cycles to failure	Temperature

Table 3

 3 FFE and exergies calculated over the whole test for the Al-6061 T6 (f = 10) Hz

	FFE	Total exergy destruction	Total plastic exergy
	8.09 MJ/K.m 3	2.33 GJ/m 3	0.186 GJ/m 3
	8.64 MJ/K.m 3	2.49 GJ/m 3	0.156 GJ/m 3
	9.14 MJ/K.m 3	2.63 GJ/m 3	0.139 GJ/m 3
	9.62 MJ/K.m 3	2.77 GJ/m 3	0.125 GJ/m 3
	FFE	x d T	xp T
	8.87 MJ/K.m 3	2.56 GJ/m 3	0.152 GJ/m 3

Table 4

 4 FFE and exergies calculated over the whole test for the SS 304 (f = 10 Hz)

	FFE	Total exergy destruction	Total plastic exergy
	38.87 MJ/K.m 3	11.19 GJ/m 3	14.96 GJ/m 3
	54.27 MJ/K.m 3	15.63 GJ/m 3	13.30 GJ/m 3
	54.02 MJ/K.m 3	15.56 GJ/m 3	6.86 GJ/m 3
	66.31 MJ/K.m 3	19.10 GJ/m 3	8.156 GJ/m 3
	FFE	x d T	xp T
	53.37 MJ/K.m 3	15.37 GJ/m 3	10.82 GJ/m 3
	6 Conclusion


Manuel Selva

Lionel Morel

Kevin Marquet

numap: A Portable Library For Low-Level Memory Profiling

The memory subsystem of modern multi-core architectures is becoming more and more complex with the increasing number of cores integrated in a single computer system. This complexity leads to profiling needs to let software developers understand how programs use the memory subsystem. Modern processors come with hardware profiling features to help building tools for these profiling needs. Regarding memory profiling, many processors provide means to monitor memory traffic and to sample read and write memory accesses. Unfortunately, these hardware profiling mechanisms are often very complex to use and are specific to each micro-architecture. In this work, we present numap, a library dedicated to the profiling of the memory subsytem of modern multi-core architectures. numap is portable across many micro-architectures and comes with a clean application programming interface allowing to easily build profiling tools on top of it.

I. INTRODUCTION

The increasing number of cores sharing memory in a single computer system leads to the so-called memory wall. The memory subsystem can not satisfy the simultaneous requests of all the cores and thus becomes a serious performance bottleneck. To alleviate this issue, computer architects have proposed many changes to memory architectures [START_REF] Molka | Cache coherence protocol and memory performance of the intel haswell-ep architecture[END_REF]. In particular, new cache levels have been added to processors and new distributed shared memory architectures, also known as Non Uniform Memory Access (NUMA) architectures, have been designed. However, these innovations have increased the burden on the software for getting the best possible performance out of the hardware [START_REF] Blagodurov | A case for numa-aware contention management on multicore systems[END_REF], [START_REF] Lepers | Thread and memory placement on numa systems: Asymmetry matters[END_REF]. In other words, the software must be aware of the underlying memory organization to efficiently exploit these complex memory architectures. Nevertheless, statically knowing the memory architecture details is not enough to exploit it efficiently. In particular, the dynamism of modern operating systems and applications leads to a form of non-determinism regarding the memory hierarchy usage. As a consequence, software developers need runtime profiling mechanisms to deeply understand how the software interacts with the memory and to identify memory bottlenecks. To allow low-level performance measurement, modern processors now provide hardware profiling mechanisms often referred to as Performance Monitoring Unit (PMU). Intel, AMD and ARM all include a PMU in their processors.

As far as memory is concerned, PMUs usually allow for two modes of operation. A first mode permits to count the number of memory requests that reach the memory controllers. From this count, one can monitor the memory bandwidth. A second mode, named sampling, periodically records samples that can contain more information about the initiator of the memory request, typically the address of the instruction that initiates the request, the level into the memory hierarchy where the data was found and information about the latency of the access.

Unfortunately, using these profiling mechanisms is a daunting task because of low-level concerns. In particular, it requires writing micro-architecture dependent code to assign the correct model specific registers (MSR) with the correct configuration values. This code can be different even for different microarchitectures from the same processor vendor.

From the programming point of view, the increasing complexity of hardware platforms has led to the emergence of numerous concurrent programming models. Custom profiling tools are then needed, that ought to be aware of the way the application is written. In order to provide useful performance information to the application developer, low-level profiling events should be linked to the programming model. An abstraction of the memory profiling capabilities of the hardware is thus required as a basic building block of these high-level profiling tools. This will allow to isolate and alleviate the difficult task of using the PMU from the other difficult task of correlating performance samples with programming models. Several existing libraries provide programming abstractions on top of the PMUs, but none of them handle the sampling of memory requests. Moreover, none of these approaches propose a portable way of monitoring memory bandwidth using the PMU in counting mode.

The main contribution of this work is the numap low-level memory profiling library. numap stands for Non Uniform Memory Access architectures Profiling. numap abstracts the common memory profiling mechanisms exposed to software by processors from different vendors by providing a powerful yet simple interface. It is an open source library 1 that already supports many micro-architectures from Intel. numap has been initially thought and designed for profiling memory usage on NUMA architectures but it can definitely be used for memory profiling in centralized shared memory systems.

The remainder of the paper is organized as follows. We describe in Section II PMUs and how to use them. In Section III we present related work. We then motivate the proposal of the numap library in Section IV. Section V gives the details of the library interface and implementation while Section VI presents an example of using the library for profiling programs written in a high-level dataflow programming language. Finally, we conclude and describe future works in Section VII.

II. BACKGROUND

In this section we first describe the different features provided by PMUs. Then we present how to access these features.

A. Performance Monitoring Unit

A PMU provides means to characterize hardware usage through hardware performance counters. These counters can be configured by software to count some specific hardware events among a huge number of possibilities. As shown in Figure 1, counters are either located at the level of cores or at the level of memory controllers. At core level, examples of hardware events that can be profiled are clock cycles, number of floating point instructions, number of level 1 cache misses or number of branch mispredictions. At memory level, counters can be configured to count the exact number of memory read or memory write requests.

In addition to this counting mode, most PMUs provide a sampling mode for events at core level. Intel's technique for sampling is called Precise Event-Based Sampling (PEBS) [START_REF]Intel R 64 and IA-32 Architectures Software Developer's Manual[END_REF] and AMD's is called Instruction-Based Sampling (IBS) [START_REF] Drongowski | Instruction-based sampling: A new performance analysis technique for amd family 10h processors[END_REF]. On Intel platforms, when sampling, instead of counting the occurrences of a specific event, the PMU is configured to generate a sample with detailed information every time the event occurred a specified number of times. On AMD platforms, IBS allows sampling all instructions independently of a particular event. On both Intel and AMD platforms, information that can be recorded in samples includes the address of the instruction that has generated the event and, in the case of memory-related events, the targeted memory address, the memory level that served the memory access and latency of the memory access. From this information, one can associate low-level information about memory accesses to source code.

B. Performance Monitoring Unit Usage

Using hardware monitoring counters requires a deep understanding of the processor's architecture and requires to write very low-level code. On Intel and AMD architectures, the PMU is accessed through Model Specific Registers (MSR) that can be written in processor's supervisor mode only. Figure 2 illustrates various ways to access these registers on top of Linux.

First, a kernel module can be used, such as the /dev/cpu/msr standard module. This module only allows to access the PMU configuration registers in supervisor mode, it does not provide any abstraction. Second, the perf_event_open system call can be used. It was introduced to support the Linux perf command line profiler [6], and provides a first level of abstraction to access hardware performance counters. This system call abstracts the need to manually write bits to MSRs to start and stop hardware profiling. Nevertheless, much work is still required from the developer willing to profile his/her applications.

For both solutions, the first difficulty consists in finding which events corresponding to memory accesses to count or to sample. The PMU events to be used are obviously different across processor vendors, but they are also different between micro-architectures from the same vendor. Finding them requires to step into the specific documentation for the targeted micro-architecture and to understand the low-level details of the underlying hardware. This task is daunting and time consuming.

In the case of perf_event_open, another important difficulty lies in understanding how to set-up all the parameters to be passed and which other system calls need to be invoked. To support this claim it is worth mentioning that the corresponding man page2 is 1583 lines long. Figure 3 shows the signature of perf_event_open. Quoting the man page, "the pid and cpu arguments allow specifying which process and CPU to monitor. The group_fd argument allows event int perf_event_open(struct perf_event_attr * attr, pid_t pid, int cpu, int group_fd, unsigned long flags); Fig. 3. perf_event_open system call signature. Parameters specify what and when to count or to sample. The system call returns a file descriptor to be used for reading count value or access recorded samples.

groups to be created". Note that the pid argument is not a process id but a thread id. The flags argument is mainly used to associate a new event to an existing group. Finally, and quoting the man page again, the attr structure argument provides "detailed configuration information for the event being created". This structure contains all the hardware-dependent information, in the form of raw numbers, the meaning of which depends on the micro-architecture. The system call returns a file descriptor to be used for reading count values or access recorded samples. When sampling is required, the user code that calls perf_event_open must use the returned file descriptor to allocate memory where the kernel will record samples. When this allocated memory is full, the kernel can not record samples anymore until user code indicates which samples it has already read. Section IV shows in detail the complexity of using perf_event_open to sample memory reads on a particular Intel micro-architecture.

III. RELATED WORK

This section first focuses on work regarding how to use the PMU. We then review existing profiling tools that use memory sampling capabilities.

A. Libraries For Accessing PMUs

To hide either the complexity of perf_event_open or the one of using directly the /dev/cpu/msr kernel module, two libraries are widely used today as shown in Figure 2. Their main goal, is to provide abstractions for common profiling mechanisms based on the PMU. The first library is Intel PCM [7]. It is available for both Linux and Windows. Nevertheless, it does not provide access to memory sampling features and as the name suggests is designed specifically for Intel processors. The second widely used library aiming at simplifying the use of PMUs of different architectures is PAPI [START_REF] Dongarra | Using papi for hardware performance monitoring on linux systems[END_REF]. It provides an abstraction for the common counters found on all the targeted architectures in such a way that the programmer only needs to say, e.g., "I want to count the number of instructions retired". Unfortunately, as Intel PCM, the current PAPI version 3 (5.4.3) does not provide any way to use the memory sampling capabilities of modern PMUs. Moreover, counting memory requests using PAPI requires to know which hardware event to use for every targeted micro-architecture. A work proposing the addition of sampling capabilities in PAPI has been published very recently [START_REF] Lopez | A prototype sampling interface for papi[END_REF]. The main difference between this work and our proposed numap library concerns the interface exposed to user code. The authors of this work advocate for a low-level interface -"PAPI sample init() is intended as a low-level interface, we have left setting up the buffer, handling the interrupt, and parsing the buffer to the user" -while we advocate for a higher level of abstraction to let developers using numap focus only on analyzing the data and not on how to get the memory samples. Moreover, to the best of our knowledge, this PAPI extension is not open source and its official integration into PAPI is not planned yet.

B. Profilers And Runtimes Using Memory Sampling

We now review existing profiling and runtime software approaches that are based on memory sampling capabilities. These tools are either non portable or require very expensive work to support different micro-architectures. All of them, except the Linux perf profiler, could benefit from numap to ease their development and to increase their portability.

The Linux perf [6] command line profiler provides a memory sampling feature. It is portable on all the processors supported by Linux. perf is based on the perf_event_open system call and hardware dependent code is developed by Linux kernel developers for supporting various models. It is a very complex tool designed to be used by end users. The only provided interface is the command line, no Application Programming Interface (API) is provided. As a consequence, compared to numap, it is impossible to build programming model aware profilers on top of perf.

Memphis [START_REF] Mccurdy | Memphis: Finding and fixing numa-related performance problems on multi-core platforms[END_REF] and MemProf [START_REF] Lachaize | Memprof: A memory profiler for numa multicore systems[END_REF] are memory profilers dedicated to identify remote memory accesses in parallel applications running on NUMA architectures. These tools work only for AMD processors and required the development of a specific Linux Kernel module dedicated to memory sampling on AMD processors based on IBS [START_REF] Drongowski | Instruction-based sampling: A new performance analysis technique for amd family 10h processors[END_REF]. Carrefour [START_REF] Dashti | Traffic management: A holistic approach to memory placement on numa systems[END_REF] is a runtime extension of MemProf integrated into the Linux kernel memory management subsystem. Its main goal is to limit remote memory accesses on NUMA architectures and to alleviate memory load imbalance. As MemProf, Carrefour required expensive developments only for running on AMD processors. HPCToolkit is a profiler that has been recently extended to support memory profiling [START_REF] Liu | A tool to analyze the performance of multithreaded programs on numa architectures[END_REF]. These extensions were required to identify memory bottlenecks in parallel applications. This profiler is portable on different micro-architectures. It relies on PAPI for the profiling aspects not related to memory and relies on micro-architecture dependent code for memory sampling. ScaAnalyzer [START_REF] Liu | Scaanalyzer: A tool to identify memory scalability bottlenecks in parallel programs[END_REF] is another extension to HPCToolkit allowing to detect memory scalability bottlenecks. It also relies heavily on memory sampling, and required a lot of development to support different micro-architectures. The development of all these tools could be easier using the numap library.

IV. MOTIVATION

As stated in the previous section, none of the existing PMU libraries provide high-level abstractions for memory sampling. More specifically, they do not provide any abstraction for techniques like Intel PEBS and AMD IBS. Developers willing to analyze memory usage and performance thus have to use the perf_event_open system call or MSRs to setup memory profiling. Again, using any of these two solutions requires to find which event to profile in the documentation of the targeted processor and to write a lot of setup code. We now describe step by step how to do memory sampling using perf_event_open.

Once a developer knows which event he/she needs to use for memory sampling using perf_event_open, the first thing to do is to setup the parameters and then to effectively make the call using these parameters. Figure 4 illustrates this task. Line 3 specifies the memory load event that must be recorded for the Intel Westmere micro-architecture in this case. This event is part of the several hundreds of events documented in processors' datasheets (Intel's Software Developer Manual [START_REF]Intel R 64 and IA-32 Architectures Software Developer's Manual[END_REF] chapter 18 for Intel processors). Line 4 specifies that a sample must be recorded only if the latency of the read access is above 3 cycles (which is the minimal latency for a memory load on the considered Westmere platform). Then, line 5 indicates the rate at which sampling must occur. This rate is in number of events. In this example, we record a sample every 20000 memory loads. In practice, the sampling rate will depend on the hardware cost of sampling memory accesses and on the acceptable overhead. The acceptable overhead for profiling tools dedicated to offline analyzes should be greater than the one for runtime decisions based on memory sampling. Lines 6 to 8 indicate which information must be recorded in each sample. Lines from 9 to 14 configure other details about the memory sampling. In these lines we indicate that we want precise recording of the instruction address, that we want to record mmap information for offline symbol decoding and that we exclude kernel and hypervisor code from sampling. Line 17 finally performs the system call and we get a file descriptor as a result. In this example, the kernel is told to record samples only for the Linux thread with the given TID identifier.

Once the perf_event_open call has been issued, user code must map the memory containing the records in its address space. User code must also effectively start the sam- pling using another system call, namely ioctl. Figure 5 shows how to do these two tasks. The mmap system call must be used with the file descriptor previously returned by perf_event_open with a particular size and with the appropriate protection arguments. As shown on line 6, the size of the mapped memory area must be in the form 1 + 2 n pages where pages is the system default page size. Finally, the ioctl call should be made twice with two specific perf flags to first reset and then start the sampling (lines 10 and 11).

When user code wants to stop sampling, an ioctl call must be performed (symmetric to the one to start sampling) as shown in line 4 of Figure 6.

To analyze the samples, extra precautions should also be taken as shown by lines 7 to 19 in Figure 6. First (line 7) we must get the position of the last sample written by the kernel to know when we have to stop reading the samples. Then, a memory barrier instruction should be issued (line 8) as specified in the perf_event_open man page ("On SMPcapable platforms, after reading the data head value, user space should issue an rmb()"). Lines 9 and 10 get the address of the header of the first sample. From then on, we can iterate over samples whose body is located at address header + 8 as shown by lines 12 to 19.

V. THE LIBRARY

We propose the numap library to alleviate developers from knowing which exact hardware events need to be used for monitoring memory bandwidth and sampling memory requests. numap also remove most of the burden described in the previous section when using perf_event_open. By automatically choosing the correct event for the underlying hardware, numap provides a portable support for low-level memory profiling.

A. Application Programming Interface

The main functions of the numap API are shown in Figure 7. These functions count memory requests, generate memory samples and provide access to them for analyzing memory behavior of applications.

Because numap relies on specific hardware components and operating system configurations, it can sometimes be complex just to know whether or not memory sampling is available on particular machine. To alleviate this problem, all the numap functions return an integer for error management. From this error code, user code can get a human readable message using the error_message function. The message may indicate that the micro-architecture does not provide memory sampling, that numap does not support yet the micro-architecture or that the system policy does not allow memory sampling along with information about how to enable it.

All functions except the error management one, take a custom structure as a parameter that is used both to provide results to the caller and to internally keep track of the events that have been activated. There is one structure for functions related to sampling and another one for functions related to counting. The definitions of these structures are shown in Figure 8.

Regarding sampling, this structure is called samp_session. It contains a list of thread ids. User code must fill this list to specify the threads to be profiled before passing the structure to functions starting profiling. The samp_session structure is also used to specify the sampling rate and the number of pages to allocate for saving the samples (this number is used to compute the size in the correct form which is then passed to the mmap call described in the previous section). The current version of numap only allows to save samples until the specified size is filled. As stated in Section VII, we plan to allow the profiling of very long lived applications. The init_samp_session function is provided to setup all the profiling parameters at once.

The samp_read_start and samp_write_start functions internally performs the mmap system call described in the previous section. There may be several calls in case the user code specifies several threads to be profiled. The result of each of them is stored in the metadatas list of the samp_session object passed as parameter. Finally, the samp_session structure contains internal fields that should only be read and written by numap itself. These fields are needed to handle all the details described in Section IV.

For counting, the structure is called count_session. It contains the list of NUMA nodes to be profiled. As for thread ids in sampling mode, user code must fill this list to specify the nodes to be profiled. The structure also contains a file descriptor for each profiled NUMA node. When counting has been stopped, user code gets the actual count value by calling the get_count function that use this file descriptor.

As shown in Figure 7, numap provides functions to start and stop profiling both for sampling and counting. The starting functions configure and start profiling according to the parameters contained in the structure object passed as parameter. In both modes, numap differentiates memory read and memory write profiling. The reason for that is the hardware, PMUs provide different events for read and write profiling.

numap also provides functions to let user code easily access the samples generated by the library. All these functions take as input the samp_session structure to avoid the user code having to deal with low-level details. The library provides functions allowing to print the samples generated by numap either in a file or on the console. To perform custom work on the generated samples, numap provides the cpy_samples function. This function produces a ready-to-use list of simple sample objects. This list is then accessible through the dest pointer. This list is dynamically allocated on the heap by numap, and its size is returned to user code through the nb_sp parameter. Each element of this list is of type struct samp. As shown in Figure 8, this structure contains the address of the instruction that generated the sample, the targeted address, the latency of the access (weight) and the memory level that served it. These values are the fundamental information needed to build appropriate profiling or runtime mechanisms such as the one described in Sections III-B and VI. This cpy_samples function alleviates the user code from the details described in the previous section required to read the memory filled by the kernel.

Figure 9 summarizes the usage of numap for sampling read memory accesses. Using numap, user code only issues 3 function calls with simple parameters. It must first call the init_samp_session function (line 3) and specify the identifiers of the threads to be profiled (line 8). In this example we are profiling only the current thread whose Then user code exploits the resulting samples. In this example, they are only printed on standard output using the numap built-in print_rd function.

identifier is retrieved through the syscall(SYS_gettid) call. Then, sampling is started just before the code to be profiled with samp_read_start (line 11) and stopped with samp_read_stop when needed (line 20). At this point the samples are available for use. Figure 9 only prints them on standard output using the numap built-in print_rd function (line 28). A real life usage of numap will deeply analyze the samples either using cpy_samples, or directly accessing the s.metadatas list. This example also shows the usage of the error_message function (lines 5, 13 and 22).

B. Implementation

The implementation of numap relies on the classic perf_event_open usage such as described in Section IV. Indeed, one of the goal of numap is to provide portability for memory profiling and perf_event_open already supports many micro-architectures.

Regarding portability, numap implementation automatically selects the correct hardware event to be used for memory read or write sampling and for memory requests counting. The set of supported micro-architectures is coded as a list of structures tagged by processor and family identifiers. For each micro-architecture, the structure contains the identifier of the events to be used with perf_event_open. This identifiers are not directly the integer representation of the events to be passed to perf_event_open but a string representation. This string is feed to the pfm library [15] which purpose is only to convert a string event to a number usable by perf_event_open. To find the string identifiers of the events to be used for each supported Intel micro-architecture, we used the software developer manual [START_REF]Intel R 64 and IA-32 Architectures Software Developer's Manual[END_REF], chapters 18 and 19. Navigating through this document is really difficult for newcomers. It requires both having a clear overview of the history of Intel micro-architectures and a lot of time to find the particular event among all the events provided. The micro-architectures currently supported are shown in Table I. As shown in this table, write accesses sampling has been introduced by Intel with the Sandy Bridge family. All these micro-architectures support counting of memory requests.

The implementation of numap hides as much as possible the details described in Section IV. Calls to perf_event_open, mmap, ioctl and memory barriers are used internally by the implementation of the numap functions. perf_event_open calls are done by the samp_xxx_start and count_xxx_start (xxx is either read or write) functions. For sampling, the starting functions also perform the mmap call. The ioctl calls needed to start and stop profiling are also done internally by numap. The cpy_samples function manages the call to the memory barrier and the conversion from the raw results provided by the kernel to the list of struct samp elements.

VI. LIBRARY USAGE EXAMPLE

numap was initiated as a mean to profile dataflow applications executed on NUMA architectures [START_REF] Selva | Performance Monitoring of Throughput Constrained Dataflow Programs Executed On Shared-Memory Multi-core Architectures[END_REF]. It started as an ad-hoc tool to evolve to a clean API to be used outside its initial scope. This section shows how we use numap to build a memory profiler dedicated to dataflow applications.

A. Dataflow Programming

In the dataflow programming model, an application is described as a graph. Each node of the graph, called an actor, represents an independent computing unit operating on input data to produce output data. Edges between actors specify the data dependencies between them and are the only mean for actors to communicate. More precisely, these edges behave as First-In-First-Out (FIFO) channels. The independence between actors and the blocking-read semantics associated to channels allow the dataflow compiler and/or runtime to automatically distribute the computing work of actors among the available cores when targeting parallel hardware.

We use numap to profile dataflow applications written using the RVC-CAL language and compiled with the Open RVC-CAL Compiler (Orcc) [START_REF] Yviquel | Orcc: Multimedia development made easy[END_REF]. This compiler is a sourceto-source compiler producing C multi-threaded code to be compiled by a standard C compiler to produce the binary, e.g., GCC.

B. Profiling RVC-CAL Applications With numap

Understanding the memory performances of dataflow applications is crucial to map them on the hardware in an efficient way. numap allows to easily get memory samples for the dataflow application in a portable way.

Figure 10 shows the profiling toolchain we implemented inside Orcc. As presented in this figure, the Orcc compiler has been modified to include memory sampling mechanisms within the generated C code. Mainly, calls to numap start and stop sampling functions are inserted each time a thread is created. The generated C source code is then linked against numap. In this instrumented C source code, when a thread is stopped, the samples are recorded to a file for offline analysis.

This offline analysis uses the information reported in each sample provided by numap in order to associate samples to channels and actors. This allows, typically, to determine the cost (in terms of latency) of an actor producing data tokens to a particular FIFO channel. This association is required to provide hints to the application programmer and the designer of the dataflow compiler. They can then modify and hopefully optimize the application and/or the compiler accordingly.

Using numap, the instrumentation of the Orcc compiler to perform low-level memory profiling was straightforward. Only few calls to the library are required without the need to understand at all how the Linux perf_event_open system call behaves and how the PMU gets the information. The numap user code (generated by the Orcc compiler in this case) just tells numap to perform memory read and/or memory write sampling for its own threads. Having a library such as numap also allows to perform very fine grain sampling, by allowing to start and stop profiling at any time.

As a result of our profiler, we get a memory cost information for all the dataflow objects involved in the execution of the program. Table II shows the profiling results of a video decoder executed on a NUMA machine made of two Intel Westmere processors. In this case, the most expensive objects regarding memory are scheduling objects and FIFO channels with identifiers 18 and 2. The scheduling objects are not visible to the programmer but generated by the compiler and are used to ensure dataflow dependencies are satisfied before executing actors. From this information, we can take better decisions regarding the mapping of the FIFO channels 18 and 2, the actors writing and reading to and from these channels and the scheduling objects.

VII. CONCLUSION AND FUTURE WORKS

This work proposes the numap library to ease the usage of memory features proposed by the PMU of many modern processors. numap is both portable and easy to use. Portability is ensured by hiding micro-architectural concerns to usercode, while usability is provided by a clean interface. We are successfully using numap as a basis of a memory profiler for dataflow applications. We believe that such libraries are required to help the software community build portable profiling tools and runtime mechanisms in an efficient way.

Nevertheless, to increase the adoption of numap we are working on several directions. First, we are currently porting numap on AMD processors. This requires to understand the details of IBS, the PMU memory sampling capabilities for AMD. This task will be nevertheless straightforward because perf_event_open already supports IBS [18], and because we gained deep experience of this system call while developing numap for Intel platforms. Independently of the complexity of porting numap on AMD micro-architectures, it is worth mentioning that our API will stay the same, because the IBS mechanism provides all the sampling attributes of the numap samp structure and because it also requires a frequency input parameter.

Second, we are planning to add better support for the management of long lived applications. Indeed, numap currently only allows to save a maximum number of events specified at initialization time. To support applications willing to process samples while running, we will extend the API with functions to indicate to the library the part of the samples already read that can be erased. This information will then be propagated to the Linux kernel to let him recycle corresponding memory pages. To support applications only requiring offline analysis of the samples, the library will provide a mechanism to automatically dump the samples into a file. This mechanism will be toggled with a simple additional parameter to the initialization function of numap.

Last, we think that the features provided by numap can and should be integrated into other profiling tools. Among those, a preferred target would be the widely used PAPI library. In a near future, the best of both numap and the memory sampling abstraction API proposed recently for PAPI should be integrated into the main version of PAPI.

15 16 /Fig. 4 .

 164 Fig.[START_REF]Intel R 64 and IA-32 Architectures Software Developer's Manual[END_REF]. perf_event_open system call complexity. This example shows how to sample memory loads for a single thread with id TID.

1 8 9Fig. 5 . 2 3 5 6 16 } 17 consumedFig. 6 .

 852516176 Fig.5. Map in user space the result of perf_event_open system call and start sampling. There are constraints on the size of the mapped memory.

Fig. 7 .

 7 Fig. 7. The main functions of numap API

Fig. 8 .

 8 Fig. 8. The numap API data structures. The structure samp_session is used by user code to specify to numap what should be profiled and to get the result. The structure samp represents a single sample.

Fig. 9 .

 9 Fig. 9. Basic usage of numap. User code must use the sequence init_samp_session, samp_read_start and samp_read_stop.Then user code exploits the resulting samples. In this example, they are only printed on standard output using the numap built-in print_rd function.

  Fig.10. RVC-CAL memory profiler based on numap. The Orcc compiler is modified to generate code including numap function calls. During the execution of the application, memory samples provided by numap are recorded for offline analysis.

	Sources RVC-CAL	Modified Orcc compilation	C sources with numap calls	GCC	Binary with numap calls	Execution	Memory Samples File	Offline analyze
			numap.so
		Source	Cost(%)
		schedWait	7.88
		sched	3.92
		FIFO-18	3.86
		FIFO-2	3.58
		TABLE II
	DATAFLOW OBJECTS WITH THE HIGHEST TOTAL MEMORY LATENCY

This work was partly supported by the Auverge-Rhone-Alpes Region, through the COOPERA Program, under the project number 16768.

https://github.com/numap-library/numap

http://man7.org/linux/man-pages/man2/perf event open.2.html

http://icl.cs.utk.edu/papi