Martine Annie Gilles
email: martine.gilles@inrs.fr

Jean-Charles Guélin

Kévin Desbrosses

Jean-Charles Guelin

Pascal Wild

Motor adaptation capacity as a

Keywords: age, work pace, motor adaptation. Highlights

de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Introduction

As in most European countries, the working population in France is ageing. Two facts have led older workers to remain at work for longer. First, the current sociodemographic situation shows that the segment of population between 55 and 65 years of age is growing due to the high birth rate from 1945 to 1974. And second, reforms to public policies related to funding for retirement pensions have postponed the age of retirement [START_REF] Dares | Emplois des seniors, Synthèse des principales données sur l'emploi des seniors[END_REF].

However, a person's health status, including physiological and psychological systems, changes as age progresses [START_REF] Seitsamo | Aging and changes in health[END_REF]Klockars 1997, Kowalski-Trakofler et al. 2005). For example, in terms of functional capacities, the knee extensors have been observed to lose strength in seniors and tendon extensive properties is known to decrease with age [START_REF] Kubo | Age-related differences in the force generation capabilities and tendon extensibilities of knee extensors and plantar flexors in men[END_REF][START_REF] Viitasalo | Muscular strength profiles and anthropometry in random samples of men aged 31-35, 51-55 and 71-75 years[END_REF]. Older employees also produce less muscular force than younger ones [START_REF] Mathiowetz | Grip and pinch strength: Normative data for adults[END_REF][START_REF] Zwart | Physical workload and the ageing worker: a review of the literature[END_REF][START_REF] Broersen | Health complaints and working conditions experienced in relation to work and age[END_REF][START_REF] Reilly | Aging, rhythm of physical performance, and adjustment to changes in the sleep-activity cycle[END_REF][START_REF] Ilmarinen | Aging and workcoping with strengths and weakness[END_REF][START_REF] Robertson | Health and productivity of older workers[END_REF][START_REF] Ilmarinen | Aging workers[END_REF][START_REF] Macaluso | Muscle strength, power and adaptations to resistance training in older people[END_REF]). These differences could be due to several factors: sarcopenia, changes in excitation-contraction coupling, modifications to the tendons and bones, and changes in nerve control [START_REF] Macaluso | Muscle strength, power and adaptations to resistance training in older people[END_REF]De Vito 2004, Narici andMaffulli 2010). These changes in force production with age nonetheless depend on the group of muscles analysed. Thus, the strength of the lower limbs appears to be more affected by age than that of the upper limbs [START_REF] Viitasalo | Muscular strength profiles and anthropometry in random samples of men aged 31-35, 51-55 and 71-75 years[END_REF][START_REF] Lynch | Muscle quality. I. Age-associated differences between arm and leg muscle groups[END_REF], Narici and Maffulli 2010). This difference is linked to preferential atrophy of the lower limb muscles [START_REF] Doherty | Aging and sarcopenia[END_REF][START_REF] Janssen | Skeletal muscle mass and distribution in 468 men and women aged 18-88 yr[END_REF], Mascaluso and De Vito 2004, Narici and Maffulli, 2010). In the long-term, this atrophy may cause older people to adopt a sedentary lifestyle. The upper limbs are more preserved as a great proportion of daily manual activities involves these muscle groups (Kornatz et al. 2005, Narici andMaffulli 2010).

These physiological data illustrate older workers the potential embrittlement. It can explain why they are more likely to develop musculoskeletal disorders than younger workers [START_REF] Kim | Leg strength comparison between younger and middle-age adults[END_REF]). In addition, although most older employees still seem fit enough to continue their work, the fact that they require longer to recover after working and sustained effort cannot be ignored [START_REF] Kiss | Differences between younger and older workers in the need for recovery after work[END_REF][START_REF] Cote | Reference values for physical performance measures in the aging working population[END_REF]. Moreover, the burden of years of work can be seen in how functional capacities evolve. Indeed, several studies have shown a strong correlation between the increase in age-related mobility problems and deterioration of hip and knee joints due to occupational exposure [START_REF] Maetzel | Osteoarthritis of the hip and knee and mechanical occupational exposure-a systematic overview of the evidence[END_REF][START_REF] Rossignol | Primary osteoarthritis of hip, knee, and hand in relation to occupational exposure[END_REF][START_REF] Werner | Risk Factors for Hip Problems Among Assembly Plant Workers[END_REF].

This general trend for fragility in older workers must nonetheless be moderated by the itinerary of the individual concerned. This life course brings into play many independent factors such as lifestyle, education, practicing physical exercises, socioeconomic status, stress, and so on. However, age is not the only factor that should be taken into account when analysing workrelated efforts. For example, it is just as important to evaluate whether the physical demands required by the workplace do not exceed the employee's physical capacities (Okunribido et al. 2011). The influence of the physical load, in combination or not with age-related effects, may be revealed by the employee's motor adaptation capacities when performing tasks. This adaptation therefore requires a modification of the motor resultant represented by voluntary movement. Indeed, a number of questions must be solved by the central nervous system to compute a voluntary movement. The movement should appropriately meet the expected goal and the context in which it must be accomplished. The notion of internal models emerged as a possible system to mimic the hypothetical paths that the brain uses to determine and produce the appropriate move (Wolpert et al. 1998). Two types of internal model can be distinguished: the inverse model calculates the appropriate command to put the body into the desired articular configuration; and the forward model, which predicts the body's reactions to the command given via a system of efferent copies of motor commands [START_REF] Miall | Forward Models for Physiological Motor Control[END_REF], Wolpert and Kawato 1998[START_REF] Todorov | Optimality principles in sensorimotor control (review)[END_REF]). The decision to perform a movement is made based on a compromise between the cost and the risk after taking in a large amount of both internal and external sensorial and cognitive information [START_REF] Wolpert | Motor control is decision-making[END_REF].

When performing work on an assembly line, the motor adaptation required to correctly complete a task is continually present. Performing a repetitive movement to meet production objectives despite the environmental hazards at the moment of execution represents an additional constraint for all workers [START_REF] Kilbom | Repetitive work of the upper extremity: Part IIthe scientific basis (knowledge base) for the guide[END_REF]. However, the time constraint often involved in repetitive work becomes particularly penalising for older employees [START_REF] Derriennic | Age, Travail[END_REF][START_REF] Molinié | Âge et conditions de travail dans l'union européenne[END_REF][START_REF] Volkoff | Does intense time pressure at work make older worker more vulnerable? A statistical analysis based on a French survey "SVP50[END_REF]. [START_REF] Xu | The effect of age on the hand movement time during machine paced assembly tasks for female workers[END_REF] also observed that female workers of different ages were capable of working at a set pace with no difference in timing of hand movements. These authors assumed that older participants had to work closer to their physical limits. Indeed, compared to younger workers, older workers showed more effort in adaptation to maintain the same motion strategies in response to muscle fatigue (Qin et al., 2014a(Qin et al., , 2014b)). Moreover, time constraints can limit intra-individual variability in the motor responses observed, even for spatially and temporally constraining tasks [START_REF] Lundager | Standardized low-load repetitive work : evidence of different motor control strategies between workers and a reference group[END_REF][START_REF] Möller | Job enlargement and mechanical exposure variability in cyclic assembly work[END_REF][START_REF] Möller | Job enlargement and mechanical exposure variability in cyclic assembly work[END_REF][START_REF] Voigt | The size of cycle-to-cycle variability in biomechanical exposure among butchers performing a standardized cutting task[END_REF][START_REF] Dempsey | Influence of three principles of pacing on the temporal organization of work during cyclic assembly and disassembly tasks[END_REF]).

Nevertheless, this variability could be beneficial in protecting the health of ageing workers.

In this paper, we present the results of a controlled laboratory study in which three groups of subjects of different ages performed a standardised task at two predetermined paces. The objective was to assess the effect of age on the motor adaptation capacities of employees to a repetitive work performed at two different imposed paces. Two kinds of adaptation were analysed during the repetitive task performed. One focused more on adaptations to whole-body movement, whereas the other focused more on adaptations to upper limb movements. Our hypothesis was that older workers can adapt, but that adaptations become more difficult when pace increases. Moreover, the difficulty adapting should be more apparent for whole-body movement than for upper limb movement.

Method

Participants

Sixty-five right-handed men voluntarily agreed to participate in the experiment. Subjects were recruited based on two criteria. First, the subjects had to fall into one of the following three age groups: junior (J), 30 to 35 years old; middle-aged (M), 45 to 50 years old, and senior (S), 60 to 65 years old. The characteristics of the three age groups are presented in Table 1. Secondly, all subjects had to have worked or be still working in what is considered a "physically demanding" job to ensure homogenous evolution of functional capacities. All participants provided a complete description of their work activities throughout their professional lives. In all cases, during a large part of their careers, they either had to carry loads, or work in awkward postures performing construction or carpentry work, or working in a mechanical workshop. Participants were recruited either through a temporary employment agency or responded to small ads published in local papers. Participant's functional capacities were assessed before the experiment through flexibility tests, dexterity (based on the Purdue pegboard test (Desrosier et al. 1995)), speed of upper limb movement, and analysis of the muscular force of the upper and lower limbs. At the end of the assessment, subjects were familiarised with the task they would have to perform during the experiment by completing 10 assemblies as fast as possible. All subjects gave their free and informed consent for participation in this study, the protocol for which was approved by the Consultative Committee for the Protection of Subjects in Biomedical Research (institutional ethics committee).

Procedure

Subjects were asked to perform a repetitive mounting task during two 20-minute work sessions, at two different work paces. The conditions in which the mounting was performed were similar to those found on an assembly line. Three activity phases were identified in each mounting cycle (figure 1a):

1-A moving phase: this phase involving movement from the base part dispenser to the assembly station work at the beginning of the mounting cycle, and from the assembly station to the dispenser at the end of the cycle.

2-

A collecting phase: during this phase component partsa handle and two nutswere collected. Parts were stored under the assembly table. This phase was a motor task involving more predominantly the lower limbs.

3-An assembly phase: during this phase a handle was fixed to a base by screwing two nuts onto two threaded rods (figure 1b). This phase was performed on the assembly table. It corresponded to a motor task mainly involving the upper limbs.

Subjects were instructed to collect the exact number of component parts (one handle and two screws) for each of the mounting cycles and not to take parts in advance for subsequent tasks.

No instructions were given as to how to proceed when collecting or assembling the component parts, it was simply specified that the assembly had to be entirely completed on the assembly table. The assembly could not be completed during the journey back to the dispenser. The base dispenser and assembly table were spaced 3 m apart. The height of the assembly table was adjusted based on each subject's anthropometric proportions.

Of the three activity phases identified above, only collection and assembly were quantitatively analysed. The starts and ends of these two phases were determined using identifiable events on displacements of the anteroposterior and lateral "sacrum" joint centre (figure 2). The start of the collection phase was marked by triggering vertical descent of the sacrum. This moment was taken as zero for the time analysis, allowing synchronisation of all the mounting cycles to allow data comparison between trials and between subjects. The collection phase was further divided into three consecutive periods: i) flexion of the subject to reach for separate parts, identified by the vertical descent of the sacrum; ii) collection of the parts from their respective reservoirs; iii) extension of the subject as they returned to a standing position. The collection phase was considered completed when the sacrum returned to a position close to its initial vertical position, before stabilising at a plateau level. The assembly phase began at this same moment and ended when the subject withdrew the fully assembled component from the assembly table and began their half turn to return towards the supply site. This event was characterised by a rightwards (positive peak in figure 2) or leftwards lateral displacement of the sacrum, depending on whether the subject pivoted on their right or left foot.

The two work sessions were performed on two successive mornings, one for each prescribed work pace. The pace of work was defined as "comfortable" or "rapid". The comfortable pace required completion of one mounting cycle every 25 s, i.e., a maximum of 49 assemblies to be performed over 20 minutes. The rapid pace required one mounting cycle every 20 s, i.e., a maximum of 60 assemblies to be completed over 20 minutes. To prevent any order effect, the order in which the two work paces were performed was assigned randomly ensuring that, for each age class, as many subjects started with the comfortable work pace as with the rapid work pace. When the instructions were presented, subjects were made particularly aware of the importance of maintaining the pace of work. If they failed to comply with this condition, they were reminded of it during the experiment. The rate was imposed by the base dispenser. The experiment was designed to provide the subject with real-time information on their progress with respect to the prescribed work pace, and to allow them to correct it if necessary. The base dispenser was divided into four identifiable parts (figure 1a). This setup was used to verify whether the subject kept to the work pace as they deposited the assembled part into the same region of the dispenser after it had performed a full rotation. It was also used to calculate any delay, either caught up or accumulated, if the subject was unable to maintain the pace. The comfortable work pace was defined based on pre-tests involving ten subjects aged 22 to 55 who had to perform as many mounting cycles as possible in 20 minutes. The average time observed was consistent with the 22 s per assembly cycle determined by "Method Time Measurement" (MTM). MTM is an engineering tool used to calculate cycle times for industrial assembly tasks. Therefore, the comfortable work pace was defined as 25 s, and the rapid rate as 20 s, which corresponds to a 20% increase in pace.

Apparatus

For each mounting cycle, the forces and moments exerted on the floor were recorded using an AMTI® force plate, and those exerted on the assembly table were recorded using an ATI® sensor positioned under the assembly table. All the dynamic signals were recorded at a frequency of 200 Hz. The displacements of 37 passive markers -placed on subjects in relation to anatomical landmarks -were simultaneously measured at a frequency of 50 Hz using a Vicon 460® optoelectronic system. To perform the kinematic analysis, 14 body segments (2 feet, 2 legs, 2 thighs, the pelvis, the abdomen, the thorax, 2 arms, 2 forearms and the head) and the joint centres corresponding to the links between these different segments were reconstructed using [START_REF] Hanavan | A mathematical model of the human body[END_REF] biomechanical model of inverse dynamics. This model was developed using recordings of marker displacements combined with 67 anthropometric measurements on subjects and dynamic measurements (force plates placed on the floor and under the table ). The model was used to calculate the Euler angles of flexion-extension for the ankle, knee, hip and shoulder joints, as well as the abduction-adduction of the hips and shoulders. These angles were calculated according to the recommendations made by the International Society of Biomechanics [START_REF] Wu | ISB recommendations for standardization in the reporting of kinematic data[END_REF][START_REF] Wu | ISB recommendation on definitions of joint coordinate system of various joints for the reporting of human joint motion-part I: ankle, hip, and spine[END_REF]. For each subject, the angles analysed were determined by calculating the difference between the angle measured at the instant studied (collection or assembly phase) and that measured on a reference

Statistical analysis

Variables were recorded during each mounting cycle performed by each subject at the two work paces. The delay was compared to the prescribed time to determine the subject's capacity to adapt to the work pace. The duration of both collection and assembly phases was measured.

The amplitude, speed and lower limb angles were measured for flexion and extension movements performed during the collection phase. The upper limb angles and vertical force were measured during the assembly phase. Statistical analysis of each of these variables was based on multi-level linear models fitted using maximum likelihood, to analyse three random effects: between-subject, between-subject x work pace, and within subject. The following factors were also analysed to determine their influence: age group, pace, and their interactions; they were considered fixed effects. The approximate normal distribution of random effects was verified on histograms of the residuals. Based on these descriptions, log transformation was performed on some variables. The parameters estimated by this model were: the variance of three random effects, the effect of age group during the tests at "comfortable" pace, the effect of work pace (rapid vs. comfortable) in the youngest age group and the two interaction parameters. The interaction parameters represented the difference in effect due to work pace in the middle-aged vs. junior and in the older vs. junior groups. The threshold for statistical significance was set at p<0.05.

The first analysis explored whether senior group can adapt to the prescribed work pace. For each pace, and for all subjects in each age group, the mean values of the time spent to complete a full mounting cycle according to the mounting cycle number were calculated. The second block of analyses explored variables characterising the collection phase (vertical displacement and velocity of the sacrum joint, flexion and abduction angles for knee and hip joints) for each age group and pace, and their interactions. The third block of analyses explored the variables characterising the assembly phase (vertical force exerted on the assembly table and flexion and abduction angles for the shoulder joints) for each age group and pace, and their interactions.

Results

Keeping up with the prescribed work pace

At the comfortable pace, 5 junior, 8 middle-aged and 9 senior subjects temporarily lagged behind the prescribed pace. However, whatever the age group, the delays were always wholly caught up before the end of the work session. The other subjects maintained the pace continually without loss of rhythm (figure 3, top).

At the rapid pace, only 3 young and 4 middle-aged subjects were able to maintain the work pace without lagging. Occasional, but compensated, delays were recorded for 15 young, 12 middle-aged and 9 seniors subjects. In contrast, 2 young, 5 middle-aged and 9 older subjects fell behind at the beginning of the session but were able to stabilise the work rhythm at the pace required latter. Juniors and middle-aged subjects acquired and maintained the work rhythm after less than 5 mounting cycles, while seniors subjects needed at least fifteen parts assembled to get there. One middle-aged and 5 seniors subjects continually fell behind during the full 20minute work session (figure 3, bottom).

Performing the mounting cycle

Collection phase

Two very distinct groups of measurements were observed when inspecting the model residuals for both downward vertical sacrum displacement and sacrum velocity (figure 4). For 88% of the data, downward sacrum amplitude of greater than 0.25 m was observed, with knee angular flexion amplitudes exceeding 70°, and flexion speed greater than 0.3 m.s -1 . For the remaining 12% of data, downward sacrum amplitude was less than 0.25 m, knee flexion amplitudes were lower than 70°, and flexion speed lower than 0.3 m.s -1 . This second data group, with little or no knee flexion was composed of: 23% young, 11% middle-aged and 66% senior subjects. No differences between the two groups were observed in terms of weight, height, or back flexibility measurements. Thus, the two groups clearly identify two ways in which component parts can be collected. Consequently, for the collection phase, it was decided to restrict analysis to the replicates in which the knees were flexed; this did not result in exclusion of any individual subjects, since none of them performed this type of collection throughout the period of their work session.

Table 2 presents the statistical analysis of the variables measured during the collection phase.

The first six columns show the means (standard deviation) calculated over all trials for all subjects grouped by age group and work pace. The latest three columns present the statistical significance of the two main effects (age group and pace, respectively) and their interaction. No effect was observed for hip flexion. However, significant interactions were identified for all the other variables for the different age groups, indicating that the increase in pace had a significant effect on these parameters. These results show that, at both work paces, seniors subjects were significantly slower and showed less lower limb flexion than the two other groups. Also, all age groups showed a decrease in collection time with the increase in pace even though the effect was less pronounced for senior subjects than for other groups. No significant variation in values between the beginning and the end of the 20-minute work was observed for any of the variables at either pace (data not shown).

Assembly phase

Data from the assembly phase were homogeneously distributed. Therefore, no data were excluded from the statistical processing for this phase. Table 3 shows the results of the statistical analysis for the same variables as measured in the collection phase; the structure is the same as in Table 2. No interaction was observed for the duration of assembly or the vertical force applied on the table during assembly. In addition, no significant difference was observed for the duration of assembly for the different age groups at either of the work paces studied.

Thus, for all groups, the duration of assembly was significantly shorter when the pace increased. In contrast, differences were observed for the vertical force applied to the assembly table. This force increased significantly with advancing age and as the work pace increase.

Increasing the pace led to a similar increase in force applied for all age groups. Thus, senior subjects always applied more vertical force on the table than subjects in other groups, whatever the pace. Interestingly, an interaction between age and pace was observed for all upper joint angles, but no clear pattern emerged from these data.

The postural analysis of the lower limbs (sacrum position and hip, knee and ankle joint angles)

showed no significant differences when analysed as a function of age group or work pace; and no interaction was observed for these measurements(data not shown in Table 3).

Discussion

The aim of the present study was to assess the effect of age on motor adaptation capacities when performing a repetitive task under two imposed work paces. This task comprised a phase during which component parts stored on the floor were collected followed by an assembly phase performed on an assembly table. The collection phase addressed the question of adaptation during large-amplitude movements mainly involving the lower limbs. The assembly phase was more focused on adaptation of fine movements of the upper limbs. In this context, adaptability is considered as the capacity to modify, within a complex environment, the response dedicated to a motor task in response to changes to parameters which are internal or external to the subject.

The younger age group in our study were not as young as in many studies of interest to age.

However, as explained by [START_REF] Ilmarinen | Aging workers[END_REF] in his review of studies involving ageing workers, an adult can be considered physiologically "young" until the age of 30. The trend for declining functional capacities can become critical after the next 15 to 20 years if the physical demands of the work performed remain the same. Therefore, we assumed that the functional capacities of our young group were close to those generally described in the literature for people aged less than 30. The results from our tests of functional capacities endorsed this conclusion [START_REF] Desbrosses | Vieillissement et évolutions des capacités fonctionnelles -32ème congrès national de Médecine et Santé au Travail -Clermont-Ferrand -05-08 Juin 2012[END_REF]. Moreover, little information is available about the 30-to 35year-old group, even though this age is considered to precede a turning point in functional capacities.

Capacity to adapt to the task

When the task was performed at a comfortable work pace, all subjects could execute it as prescribed. In this condition, the external constraints can be considered to be the same as those found on a factory production line when no additional events disturb production. All subjects, regardless of age, were able to adapt their motor capacity to the requirements of the task. Thus, they were able to adapt the pace, amplitude and speed of movements required to collect and assemble component parts. However, the youngest group were better able to maintain a constant pace than the two older groups.

Adapting the rhythm of work to the fast work pace was difficult for all age groups. Only 7 of the 65 participants were able to maintain the pace throughout the duration of the test. Most of the remaining subjects managed to adapt to the pace demanded with only a few lapses of rhythm, which they always made up. The delays observed were often due to incidents such as dropping a nut when starting to screw it onto the threaded rods. In addition, the oldest subjects were less capable of increasing the speed at which parts were collected. Adaptation of motor capacities to the fast pace appeared to require more time with age.

A small number of subjects, mainly older individuals, were unable to adapt to the faster pace.

Limitations to adaptability were generally related to motor difficulties observed during collection of the parts stored on the floor, and these difficulties were further reinforced by the increase of the work pace. It therefore appears that the age-related difficulties to adapt are closely linked to use of the lower limbs in the task.

Motor capacities adaptation and lower limbs

The way the supply bins were arranged on the floor required subjects to use their whole body when collecting component parts. Our experimental set up was deliberately non-ergonomic, but unfortunately still reflects some real-life industrial work stations. Squatting to pick up loads is generally acknowledged as the correct technique to reduce the risk of back injury [START_REF] Chaffin | Manual materials handling and the biomechanical basis for prevention of low-back pain in industry -An overview[END_REF], Mc Gill et al. 1996[START_REF] Fathallah | The Role of Complex, Simultaneous Trunk Motions in the Risk of Occupation-Related Low Back Disorders[END_REF], Chaffin et al.1999). However, this technique also involves considerable movement of the trunk and requires a whole-body upwards thrust to return to the upright position. Therefore, it represents a greater physiological effort than stooping [START_REF] Kumar | The physiological cost of three different methods of lifting in sagittal and lateral planes[END_REF]). The quadriceps have been shown to be extensively involved in performing the squat technique [START_REF] Trafimow | The effects of quadriceps fatigue on the technique of lifting[END_REF]).

In our study, the speeds of flexing and extending the lower limbs were found to decrease with age. Loss of efficiency of the lower limb muscles with ageing has been previously described [START_REF] Macaluso | Muscle strength, power and adaptations to resistance training in older people[END_REF]. This loss of efficiency already appears significant for older subjects, who are nonetheless led to remain active for longer. Reduced production of muscular force at the knee joint was observed for the senior group in our study, as described in our previous publication [START_REF] Desbrosses | Vieillissement et évolutions des capacités fonctionnelles -32ème congrès national de Médecine et Santé au Travail -Clermont-Ferrand -05-08 Juin 2012[END_REF]. This reduced force affected the kinematics of large-amplitude rapid movements. These results match those described in the review by [START_REF] Duchateau | Évolution et adaptations à l'entraînement du système neuromusculaire au cours du vieillissement[END_REF], and the loss of efficiency increases as the pace accelerates. Even so, senior subjects can still adapt to a faster pace. Thus, they can increase flexion and extension speeds to follow the rapid pace. However, their overall speed remains slower than that measured for younger subjects.

Fatigue does not appear to be an explanatory factor of this study. Indeed, no variation in speed was measured over the 20-minute tests, whatever the age group or pace. The most significant problem faced by the senior group seems to be a loss of capacity to link actions. Thus, older subjects could no longer use the time spent squatting as a means for adaptation. Younger subjects, in contrast, could minimise the time spent squatting to collect component parts by linking flexion and extension in one movement. However, with increasing age, it becomes more difficult to reduce this time. This observation can be explained by the fact that force production is more affected during rapid movements than during slow movements [START_REF] Duchateau | Évolution et adaptations à l'entraînement du système neuromusculaire au cours du vieillissement[END_REF]). Therefore, it seems that younger subjects have sufficient potential strength to "smooth" the three actions of "flexiontaking partsextension" into a single movement as the work pace increased. Conversely, the reduction of muscular strength with increasing age accentuated the dissociation of these actions into distinct movements during collection of parts.

The major constraint imposed on the lower limbs by the squat appears to be avoided by using a stooping technique (Trafimov et al. 1993). However, stooping still demands significant effort from the back muscles [START_REF] Van Dieën | Stoop or squat: a review of biomechanical studies on lifting technique[END_REF][START_REF] Zhang | Back lift versus leg lift: an index and visualization of dynamic lifting strategies[END_REF][START_REF] Bazrgari | Analysis of squat and stoop dynamic liftings: muscle forces and internal spinal loads[END_REF]). Thus, squatting was the mode most often used by our population to collect parts from the floor.

Nonetheless, we observed that senior subjects systematically reduced the pelvis lowering distance. From our observations it is impossible to report a passage from squatting to stooping, unlike with the fatigue induced by the tasks observed by Trafimov et al. (1993). Indeed, the amplitude of knee flexion in older subjects in this study was within the range defining a squat (Whitney 1958, Burgess-Limerick and[START_REF] Burgess-Limerick | Toward a quantitative definition of manual lifting postures[END_REF].

Squatting was thus used most in our study. Perhaps this observation can be correlated with the extensive campaigns aiming to prevent back pain. Nonetheless, when no recommendation was given to participants, a small percentage of subjects stooped to collect parts. Interestingly, the population using a stooping technique was mostly composed of senior subjects. We do not have information on the reasons why subjects chose to use one technique or the other. In addition, we cannot explain why they varied from one to the other during a work session. However, these habits or changes were independent of the subjects' back flexibility, height or weight.

Fluctuations between squatting and stooping were also observed by Burgess-Limerick et al.

(2001) in young subjects. For these authors, the transition from one technique to the other appeared to be part of a compromise between the biomechanical advantages of the two techniques, and the influence of lifting height on this compromise. However, in our study lifting height was constant as parts were always placed on the floor; it was therefore not a determinant factor. In addition, stooping did not appear to be systematically linked to a desire to save time. Indeed, for subjects using both techniques, changing from one to the other was not always linked to increase pace. Since stooping was mainly observed with senior subjects, loss of strength and action speed of the different lower limb muscles emerges as the dominant hypothesis explaining its use.

Motor capacities adaptation and upper limbs

The second phase analysed in this study was the assembly of the component parts following their collection. This phase is more linked to fine motor skills. The upper limbs are involved in completing a task requiring manual dexterity, while the lower limbs are used to regulate postural balance. As expected, the posture of the lower limbs, strongly conditioned by the arrangement of the workstation, was not modified by age or work pace. Similarly, although statistical differences for shoulder angles were observed, their amplitude variations were low and they were difficult to interpret.

In relation to upper limb motricity, both gross [START_REF] Mathiowetz | Grip and pinch strength: Normative data for adults[END_REF] (1995). Nonetheless, during assembly, this reduction did not appear to be a major obstacle to completing the task. In fact, at both work paces, all age groups completed the assembly within similar time frames. In addition, the loss of fine dexterity did not appear to interfere with the adaptation process, as all subjects reduced the duration of this phase to a similar extent when the pace increased.

However, as the fine movements of the fingers could not be recorded during the experiment, it is not possible to determine whether or how age affected the method used to adapt the way parts were assembled. Adaptability of all subjects to the pace could be supported by the fact that senior subjects preserved muscular force in their upper limbs, with the same fatigability as for younger subjects [START_REF] Macaluso | Muscle strength, power and adaptations to resistance training in older people[END_REF]De Vito 2004, Duchateau et al. 2006). However, the similar speeds recorded for older subjects and the youngest subjects during the assembly phase contrasted with results reported by [START_REF] Cole | Slowing of dexterous manipulation in old age: force and kinematic findings from the "nut-and-rod" task[END_REF]. This apparent discrepancy could be explained by the fact that our seniors group was younger than theirs. Indeed, the senior participants in our study had only recently retired or were still at work, and the strength in their upper limbs was similar to that measured for the younger groups [START_REF] Desbrosses | Vieillissement et évolutions des capacités fonctionnelles -32ème congrès national de Médecine et Santé au Travail -Clermont-Ferrand -05-08 Juin 2012[END_REF]). In addition, we must keep in mind that the fine motor skills observed here concerned essentially engaging nuts on threaded rods. This task accounts only for a part of the assembly phase, with a much larger proportion of time spent screwing the nuts into the end position, which requires less fine motor skill.

Nevertheless, while seniors participants were able to adapt their assembly time to meet the required pace, they always applied more force during assembly than the youngest subjects.

Increased grip force with age when handling objects between two fingers has been well documented [START_REF] Cole | Grasp force control in older adults[END_REF][START_REF] Cole | Mechanisms for age-related changes of fingertip forces during precision gripping and lifting in adults[END_REF][START_REF] Parikh | Handling objects in old age: forces and moments acting on the object[END_REF]. Part of the explanation given by these authors was that it increases the safety margin to avoid dropping the object when holding it still or moving it. This adaptation would compensate the lack of sensitivity due to advancing age. Motor coordination between grip force and the vertical acceleration of an object is not affected by advancing age [START_REF] Gilles | Age-Related Changes in Grip Force and Dynamics of Hand Movement[END_REF]. However, several factors may be causally related to the increase of grip force. The way in which an object is gripped and manipulated can differ with age, and may modify the level of force in the grasp [START_REF] Cole | Slowing of dexterous manipulation in old age: force and kinematic findings from the "nut-and-rod" task[END_REF]. A lack of well-coordinated synergy between fingers has been observed for older subjects, and was linked to an increase in force [START_REF] Olafsdottir | Age-related changes in multifinger synergies in accurate moment of force production tasks[END_REF]). Another effect is increased lateral wrist speed, which is also known to increase the force applied [START_REF] Werremeyer | Wrist action affects precision grip force[END_REF].

We also need to take into account the fact that the assembly tasks in our study combined work by both hands. It is therefore difficult to attribute the increase of vertical force exerted on the table to the action of one hand or the other. The increasing force may either result from greater pressure exerted by the hand stabilising the object on the table, or from stronger force from the hand screwing the nuts to final position, or from a combination of the two. Regardless of its origin, the overall force increased with age and work pace. Thus, increasing the pace augments the force used. The two adaptation processes were combined by senior subjects who increased constraints and efforts when performing the required movements over long shifts. This increased use of force in seniors is another factor explaining why older workers are more susceptible to develop musculoskeletal disorders.

In conclusion, most subjects in the three age groups studied could adapt their motor capacity to comply with an increased work pace when performing a prescribed repetitive task. However, adaptation in older subjects was less effective than in younger subjects, with older subjects taking longer to implement the increased pace, and some failing completely. Different types of adaptation can be distinguished. Some appear to be related to the time constraints imposed by the work pace. For example, this was observed during collection of the component parts by the reduction in the amplitude of lower limb flexion; when assembling the parts, it was illustrated by the increase in vertical force applied by the hands. Other adaptations appear to be more specifically linked to the change of physical capacities with age. For instance, younger subjects were better able to increase the speed of lower limb movement, whereas older subjects further increased the vertical force applied when assembling parts. Although older subjects were capable of performing the assemblies under the different imposed conditions, increasing the work pace exacerbated their motor limitations. These limitations were particularly present when movements performed mainly involved the lower limbs. In contrast, tasks involving the upper limbs were less exclusive to older subjects being capable of performing them at the same speed as younger subjects. The motor adaptations observed provide us with a better understanding of the additional efforts required from workers when responding to an increased work pace, whatever their age. However, in our task, assembling parts can be considered as the core of the work performed, as it required certain skills. In contrast, collecting parts is an ordinary action required to complete the assembly. Thus, senior workers were still able to perform the core of the task correctly. If the workstation had been more ergonomically designed, they would have had less difficulty completing the prescribed task. This knowledge could be helpful in maintaining an older working population in conditions which help protect their health.

Figure 1: Experimental set-up a) Work station: three activity phases were identified during each mounting cycle: i) a moving phase between the base dispenser and the assembly table before and after collecting and assembling the parts; ii) a collecting phase where the subject grasped a handle and two nuts in the stock of component parts; iii) an assembly phase performed on the assembly table, where the subject assembled the parts. The base dispenser was divided into four identifiable parts so that subjects could check their conformity with the pace and calculate possible delays. 13.94 (24.17) < 0.001 < 0.001 < 0.001 Table 2: collection phase data statistical analysis: only data with sacrum vertical down amplitude higher than 0.25 m and a flexion velocity higher than 0.3 m.s -1 were retained for this analysis. Mean values (sd) of all the tests for each group of subjects obtained for each variable considered during each pace. t = time; a = amplitude, v = velocity; F = flexion; A = Abduction.

  posture. The reference posture corresponded to subjects standing with their feet aligned vertically below the hips, with a straight back. Upper limbs were aligned along the body with the palms of the hands facing the outer thighs. The reference posture was recorded before starting each work session. Ankle flexion increase corresponded to inclination of the anterior face of the leg towards the instep. Knee flexion increase was defined as closing in of the posterior face of the leg towards the posterior face of the thigh. Hip flexion increase corresponded to inclination of the anterior face of the trunk towards the anterior face of the thigh. Shoulder flexion increase was defined as raising the anterior part of the arm in the sagittal plane. For hip and shoulder joints, abduction increase corresponded to displacement of the member outside the median plane of the body, in the frontal plane.

  and fine(Desrosier et al. 1995) dexterity are known to diminish after age 60. During tests performed to assess the functional capacities of the subjects participating in this study[START_REF] Desbrosses | Vieillissement et évolutions des capacités fonctionnelles -32ème congrès national de Médecine et Santé au Travail -Clermont-Ferrand -05-08 Juin 2012[END_REF], we observed a reduction in fine dexterity comparable to that described by Desrosier et al.

Figure 2 :

 2 Figure1: Experimental set-up a) Work station: three activity phases were identified during each mounting cycle: i) a moving phase between the base dispenser and the assembly table before and after collecting and assembling the parts; ii) a collecting phase where the subject grasped a handle and two nuts in the stock of component parts; iii) an assembly phase performed on the assembly table, where the subject assembled the parts. The base dispenser was divided into four identifiable parts so that subjects could check their conformity with the pace and calculate possible delays. b) Assembly: (left) parts before assembly: a base composed of a wooden block into which two threaded rods are inserted, a handle and two nuts; (right) the assembled parts. Assembly consisted in placing the handle on the threaded rods and fixing it with the two nuts.

Figure 3 :

 3 Figure3: Mean capacity for Junior (blue), Middle-age (red) and Senior (green) groups to conform to the comfortable or rapid paces imposed for the task. The base dispenser was set up to control how well the subject groups worked in rhythm. The delay is calculated from the mean value for all the subjects from a single age-group, the time required to complete a full mounting cycle (moving phase + collection phase + assembly phase). The expected response is a plateau value equal to 0. If subjects persistently perform more slowly than the pace required, the curve rises. If they catch up, the curve drops. If the work rhythm stabilises to correspond to the imposed pace the curve reaches a plateau.

Table 1 :

 1 Mean (range) characteristics for the three subject groups.

	Subject characteristics	Junior	Middle-aged	Senior
	Number of subjects	20	22	23
	Age (years)	32.6	47.1	61.8
		(30-35)	(45-50)	(60-65)
	Body Mass (kg)	74.9	78.1	81.2
		(53-103)	(60-110)	(62-106)
	Height (m)	1.77	1.74	1.74
		(1.55-1.87)	(1.63-1.91)	(1.65-1.88)
	Body Mass Index	23.91	29.39	29.82
		(22.06-29.45)	(22.58-30.15)	(22.77-29.99)

Table 3 :

 3 assembly phase data statistical analysis: mean values (sd) for all tests performed with each group of subjects obtained for each variable considered during each pace. t = time; F = flexion; A = abduction.

		Comfortable pace		Rapid pace			p values
		Junior Middle-	Senior	Junior	Middle-	Senior	between	between	inter-
			aged			aged		age	pace	action
	t-assembly	12.7	12.0	12.8	11.4	10.7	11.3	0.08 < 0.001	0.92
	(s)	(2.5)	(2.8)	(2.8)	(2.6)	(2.8)	(3.1)
	Vertical	22.11	23.30	28.00	22.54	26.46	31.46	0.002 < 0.001	0.08
	force (N)	(6.11)	(8.73)	(8.91)	(7.68)	(9.48)	(10.71)
	F-right	25.00	25.95	33.44	27.43	30.06	35.88	0.02 < 0.001 < 0.001
	shoulder (°)	(12.52)	(12.43)	(14.60)	(10.97)	(12.88)	(12.81)
	F-left	23.84	23.55	32.70	29.32	29.49	34.25	0.02 < 0.001 < 0.001
	shoulder (°)	(10.95)	(10.39)	(12.45)	(11.14)	(11.12)	(12.37)
	A-right	2.65	5.88	5.70	2.42	4.97	4.04	0.32	0.42 < 0.001
	shoulder (°)	(8.01)	(10.02)	(7.94)	(10.04)	(8.77)	(10.57)
	A-left	10.89	13.87	10.24	12.04	11.40	12.70	0.20 < 0.001 < 0.001
	shoulder (°)	(8.77)	(9.17)	(6.46)	(9.24)	(9.23)	(7.80)


Pierre Guillou

Benoît Pin

Fabien Coelho

François Irigoin

A Dynamic to Static DSL Compiler for Image Processing Applications

Keywords: Dynamic Language, DSL, Compilation

High-level interpreted programming languages, such as Python, are widely used because of their concise syntax and dynamic type system, which allow programmers to efficiently develop applications. However, they cannot offer the same guarantees provided by lower-level languages such as C in terms of portability on embedded systems. Is it possible for dynamic applications to benefit from lower-level compilation toolchain in order to increase their portability onto specialized hardware targets? We present in this paper (1) a methodology to convert a dynamic Domain-Specific Language (DSL) into a static one that preserves programmability, (2) a working implementation that takes care of types, memory allocation, polymorphism and API adaptation between the two DSLs, (3) and experimental results on portability and performance that show the efficiency of our approach. We illustrate our methodology with two image processing libraries: SMIL and FREIA. The SMIL library is a C++ image processing library offering ease of programming with a Python wrapper. However, SMIL applications also have to be executed on embedded platforms such as FPGAs on which a Python interpreter is not available. The generic answer to such an issue is to re-code the original Python applications in C or C++, which will be then optimized for every hardware target, or to try to compile Python into native code using tools such as Cython. The approach we suggest here is to ease portability of applications written in a DSL embedded in C (the FREIA API) by using specific optimizations such as image expressions evaluation, removal of temporary variables or image tiling.

Introduction

Computer vision is now a fast-growing field of research and is going to play a large role in everybody's life in the near future. Augmented reality or autonomous vehicles such as drones or cars are showing more and more promises and may be available to consumers in the next decade. Figure 1 depicts an image processing application that detects macular degeneration on a retina, speeding up medical diagnoses. To support this innovative field, new image processing libraries are being developed and compete in terms of performance and programmability. Among them, OpenCV [START_REF]OpenCV: Open Source Computer Vision[END_REF], GEGL [START_REF] Irigoin | GEneric Graphics Library[END_REF], ImageMagick [START_REF]Or Compose Bitmap Images[END_REF] or NumPy [START_REF]NumPy: scientific computing with Python[END_REF] are the most well known. These libraries often provide APIs in high-level programming languages, such as Python, in order to offer good programmability. Python is a general-purpose programming language with several key features improving programmability: high-level abstractions, dynamic type system, simple memory management with garbage collection and concise and easy-to-learn syntax. It can support several programming paradigms, such as imperative, functional or object-oriented programming. However, Python programs are limited by the interpreter, which causes slower executions and needs more memory than native languages such as C or C++ [START_REF]Is Python faster and lighter than C++?[END_REF][START_REF]Is C/C++ really faster than Python[END_REF]. The interpreter also limits the parallelism of Python programs through the Global Interpreter Lock [START_REF]CPython Global Interpreter Lock[END_REF], which prevents using more than one thread. Fortunately, Python can easily be interfaced with low-level C or C++ code through wrappers to ensure native performance on parallel architectures. As a consequence, image processing libraries are often written C or C++, and provide Python bindings to increase programmability. However, in our hardware jungle era [START_REF] Sutter | Welcome to the Jungle[END_REF], substantial efforts have to be made to have those libraries efficiently running onto all kinds of modern accelerators, such as GPUs, FPGAs or many-core processors. Production compilers are not yet able to target the whole range of today's hardware: it is up to developers to provide an optimized version of their library onto a specific hardware. Programming models such as OpenMP [START_REF]OpenMP: Open Multi-Processing[END_REF] for shared memory, OpenCL [START_REF] Group | OpenCL: The open standard for parallel programming of heterogeneous systems[END_REF] for heterogeneous platforms or MPI [START_REF]The Message Passing Interface[END_REF] for distributed computing can help target a class of accelerators at once, but further optimizations are often hardwarespecific.

New compiler techniques must arise to support complex image processing applications without sacrificing programmability. This paper focuses on compiling high-level interpreted DSLs into lower-level but more portable ones. We validate our approach with two image processing interfaces considered as DSLs, SMIL [START_REF] Faessel | SMIL: Simple (but efficient) Morphological Image Library[END_REF] and FREIA [START_REF] Bilodeau | FREIA: FRamework for Embedded Image Applications[END_REF][START_REF] Coelho | API Compilation for Image Hardware Accelerators[END_REF], supporting each a different set of hardware targets and providing different levels of programmability. We evaluate our methodology on a set of seven image processing applications.

Context

Mathematical Morphology is an image processing theory based on lattice theory initiated in the 1960s [START_REF] Serra | Image analysis and mathematical morphology[END_REF][START_REF] Dougherty | An introduction to morphological image processing[END_REF]. Common applications of this theory consist in detecting geometric structures in images, or partitioning an image in regions. Several software libraries have been developed since the inception of this theory, each providing better performance or usability. SMIL and FREIA are two of them. good performance, using loop auto-vectorization through GCC compilation [START_REF]Auto-vectorization in GCC[END_REF] and OpenMP parallelization [START_REF]OpenMP: Open Multi-Processing[END_REF];

The SMIL library

ease of programming, through several Swig [START_REF]Swig: Simplified Wrapper and Interface Generator[END_REF] auto-generated interfaces to higher-level programming languages such as Python; portability on several CPUs and operating systems, using the CMake [START_REF]CMake: Build, Test and Package Your Software[END_REF] compilation toolchain; maintainability and extensibility, through C++ templates and functors. Figure 2 depicts an example of a SMIL script using the Python interface. This script reads an image from a file, performs an morphological dilatation on this input image and then saves the resulting image. FREIA (Framework for Embedded Image Applications) [START_REF] Bilodeau | FREIA: FRamework for Embedded Image Applications[END_REF] is a C image processing framework. It provides a C API divided into elementary and composed image operators. This API abstracts several implementations targeting different categories of hardware accelerators :

The FREIA framework

1 #include "freia.h"
multicore and vector CPUs with SMIL (through an intermediate C wrapper around SMIL C++ code); -CPUs with vector extensions through Fulguro [START_REF] Clienti | Fulguro image processing library[END_REF]; -FPGAs with the SPoC [START_REF] Clienti | A System On Chip Dedicated To Pipeline Neighborhood Processing For Mathematical Morphology[END_REF] and Terapix [START_REF] Bonnot | Definition and SIMD Implementation of a Multi-Processing Architecture Approach on FPGA[END_REF] backends; manycore CPUs such as the Kalray MPPA [START_REF] Dupont De Dinechin | Extended Cyclostatic Dataflow Program Compilation and Execution for an Integrated Manycore Processor[END_REF] with Sigma-C [START_REF] Goubier | ΣC: A Programming Model and Language for Embedded Manycores[END_REF][START_REF] Aubry | Extended Cyclostatic Dataflow Program Compilation and Execution for an Integrated Manycore Processor[END_REF], a dataflow programming language; -GPUs using OpenCL [START_REF] Group | OpenCL: The open standard for parallel programming of heterogeneous systems[END_REF].

Used in combination with our in-house C source-to-source compiler framework PIPS [START_REF] Irigoin | Semantical interprocedural parallelization: an overview of the PIPS project[END_REF], FREIA applications can be further optimized at the image operator level for the designated hardware target [START_REF] Coelho | API Compilation for Image Hardware Accelerators[END_REF][START_REF] Guillou | Automatic Streamization of Image Processing Applications[END_REF]. Performed image optimizations include complex operator unfolding, temporary variable elimination, common sub-expression elimination, backward and forward copy propagation, operator aggregation, and target-specific code generation.

Figure 3 represents an abridged version of a morphological dilatation using the FREIA API. In this example, image structures must be explicitly allocated before use and freed afterwards.

Bridging the gap

The SMIL library supports several CPU targets using the GCC compiler and the CMake toolchain. Nevertheless, porting this image processing library on specific hardware accelerators such as GPUs to take advantage of heterogeneous architectures can be a hard task. Meanwhile, the FREIA framework supports a wide range of hardware accelerators, but fails in comparison to offer easy programmability: users still have to manage memory and write C code. Several solutions are possible to reconciliate SMIL programmability and FREIA set of hardware targets. A total port of SMIL on every FREIA target is a hard and long task, and would not reuse work already done for FREIA. One can try to re-implement the SMIL API using FREIA, but this solution does not allow our C compiler PIPS to perform its optimizations. Allowing C-and Fortran-supporting PIPS to handle C++ source code to regenerate directly target-optimized FREIA code is also a lengthy process, and although it can yield some long-term benefits, it is not in the scope of this project.

In this paper, we present smiltofreia, a source-to-source compiler designed to convert SMIL applications written using the Python interface into FREIA C. Thus a SMIL application can be automatically ported to the FREIAsupported hardware targets and take advantage of the PIPS source-to-source compiler optimizations. Figure 4 represents our compilation chain highlighting the benefits of smiltofreia in terms of portability.

Manipulating and accelerating Python code

In order to analyze and convert SMIL Python applications into FREIA C, we tried two Python tools: RedBaron [START_REF]Redbaron: Bottom-up approach to refactoring in python[END_REF][START_REF] Peuch | une approche bottom-up au refactoring en Python[END_REF], a Python refactoring framework, and Cython [START_REF]Cython: C-Extensions for Python[END_REF][START_REF] Behnel | Cython: The Best of Both Worlds[END_REF], a Python-to-C compiler.

The Python standard library itself provides low-level tools to parse and query Python code. Among them, inspect [START_REF]inspect -Inspect live objects[END_REF], which can be used to inspect and modify running Python code, and ast [START_REF]ast -Abstract Syntax Trees[END_REF], for manipulating Python code Abstract Syntax Trees.

RedBaron, a Python refactoring tool

We built our smiltofreia compiler on top of the RedBaron refactoring tool. RedBaron is a high-level Python interface allowing developers to easily refactor their Python code without losing information. It is based on the Baron [START_REF] Baron | a Full Syntax Tree library for Python[END_REF] FST (Full Syntax Tree) which, unlike a traditional AST, does not drop comments and formatting data. As a consequence, regenerating source code from a FST is an invariant transformation:

fst_to_code(code_to_fst(source_code)) == source_code
For instance, the RedBaron FST of the SMIL dilatation call smil.dilate(imin, imout) from Figure 2 is represented in Figure 5. Note that the formatting information (line breaks and spaces) separating the words is kept in this data structure in order to regenerate the very same source code.

RedBaron provides an efficient and intuitive object-oriented interface to query and manipulate this FST. Top-level nodes, corresponding to actual lines of codes, can be accessed and modified through array subscripts and assignments. Transforming the dilatation in the FST fst of Figure 2, Line 4, into an image copy is as simple as rewriting the content of the corresponding node

fst[3] = "imout = imin"
The main purpose of RedBaron is to help refactoring Python code, such as generating classes, methods, or renaming variables or functions in one or several files. A canonical example of this usage can be found in Figure 6: variable imin is here renamed in in.

Compared to RedBaron, the Python standard module ast provides a clumsier interface and drops some essential formatting information, useful when refactoring.

{"type": "atomtrailers", "value": [ {"type": "name", "value": "smil"}, {"type": "dot", "first_formatting": [],

"second_formatting": []}, {"type": "name", "value": "dilate"}, {"first_formatting": [], "third_formatting": [],

"type": "call", "fourth_formatting": [],

"second_formatting": [],

"value": [ {"type": "call_argument", "first_formatting": [],

"second_formatting": [], "target": {}, "value": {"type": "name", "value": "imin"}}, {"type": "comma", "first_formatting": [],

"second_formatting": [{"type": "space", "value": " "}]}, {"type": "call_argument", "first_formatting": [],

"second_formatting": [], "target": {}, "value": {"type": "name", "value": "imout"}} ]}]} We investigated the use of Cython, a Python-to-C compiler, for generating FREIA code from our SMIL Python applications. We wrapped a subset of the FREIA API in Python using the Cython extension system, and we used RedBaron to convert SMIL applications into FREIA Python. The Cython compiler then generates a C source file from this Python code. Figure 7 shows the output of the Cython Python-to-C compiler around the FREIA dilatation call.

However, the generated source code is too low-level, and thus too far from FREIA, for our source-to-source framework PIPS to perform additional optimizations. Cython introduces a lot of new variables and functions, and uses opaque data structures, which makes the code a lot more complex to analyze. As a consequence, PIPS regeneration of optimized source code for the specific hardware targets could not work. Moreover, the generated code depends on an external library implementing a Python run-time environment, which may not have been ported on every FREIA hardware target. The Cython approach, which works well for interfacing Python and C code and hence accelerating Instead of using Cython for generating low-level C from Python, we developed an in-house Python-to-C compiler for SMIL applications. Our compiler, named smiltofreia, generates directly FREIA C code from SMIL Python applications. smiltofreia iterates over the RedBaron FST of a SMIL application and transforms each node into a corresponding C statement. An example of this compiler output is available in Figure 8. Some compatibility code and wrapper functions have been placed in a dedicated smil-freia.h header file, which explains the main differences with the original FREIA dilatation code in Figure 3. Algorithm 1 presents a broad overview of the workings of our compiler. The RedBaron tool is used to get the Full Syntax Tree of the input code. Our compiler operates on the nodes of this FST to type variables and generate C code. A pre-processing pass can generate a missing def main() function around the input code instructions as a normalized entry point for our applications. To prettify the generated C code, an optional application of the formatting tool clang-format [START_REF]clang-format:A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code[END_REF] is performed.

Algorithm 1: General description of a smiltofreia execution over a SMIL Python application

A more in-depth description of the main routine of our compiler is available in Algorithm 2. This algorithm shows the recursive approach taken to generate the C code corresponding to a FST node. Each FST node is processed according to its RedBaron type, from top-level nodes, which represent Python module-level constructs such as classes, function declarations, global variable declarations or instructions, to bottom-level ones (identifiers, operators, constants or formatting data). For instance, dealing with a Python instruction block consists in processing each sub-node.

Python is a dynamic language with a garbage collector dealing with memory allocation. A contrario, C is lower-level: variables must be declared; memory management is done by hand; and heap-allocated memory must be freed at the end of its use. Besides, SMIL and FREIA API, although close, can differ. Our compiler addresses these differences to generate code that respects the C specification and the semantics of the source SMIL application. As a consequence, our compiler input is constrained: only pure SMIL Python code without other Python modules is supported, and the type of all variables must be statically inferable.

Typing

Our compiler is focused on a subset of the SMIL API that has an equivalent in FREIA, and must also deal with issues arising when trying to generate static code from a dynamic one. We wrote a defensive implementation that puts programming constraints on the Python input code. The goal is to ensure that a successful transformation will produce a well-typed and well-memorymanaged C code. The smiltofreia compiler knows both SMIL and FREIA APIs and the correspondence between their functions' signatures. Variables are typed at first initialization and cannot be mutated. The compiler fails otherwise with a consistent error message, thanks to RedBaron FST, which provides a convenient way to locate a specific node in Python code. Function arguments are also typed and transformed before they are passed to FREIA functions.

Function polymorphism

The SMIL library features polymorphism i.e., methods can have several signatures, which requires some care when transforming. We also chose to keep real-world SMIL Python as a developer would write it as an input. However, FREIA is more rigid and needs fully-typed arguments when calling functions.

For example, we use several tricks to deal with optional parameters such as rewriting Python code on the fly to a canonical form closer to the corresponding FREIA call. For this purpose, the RedBaron ability to access and modify FST nodes is key.

The following Python code illustrates the polymorphism of the smil.dilate function regarding its last argument:

smil.dilate(imin, imout, 5) smil.dilate(imin, imout, smil.SquSE( 5))

-At Line 1, the last parameter is an integer; in this case it denotes a 5-pixel wide square structuring element. -At Line 2, the last parameter is a full-fledged structuring element.

The first line is internally modified, using RedBaron abilities to rewrite nodes, to transform the first line version into the second line version.

Image expression atomization

The SMIL library massively uses operator overloading, which eases image manipulation such as arithmetic operations etc. This allows to write expressive codes, but corresponds internally to nested calls. Our compiler manages this issue, sometimes by generating intermediates variables. Operands can also be API calls. Since FREIA calls do not return images pointers, SMIL arithmetic expressions are decomposed into their atomic three-address code forms. Red-Baron helps us by taking care of operators precedence. For instance, the following SMIL expression:

out = in0 * in1 + ((in2 -in4) | (in5 & in1)
is transformed in the five following FREIA operator calls, according to the semantics of the operators: freia_aipo_mul(tmp0, in0, in1); freia_aipo_sub(tmp1, in2, in4); freia_aipo_and(tmp2, in5, in1); freia_aipo_or(tmp3, tmp1, tmp2); freia_aipo_add(out, tmp0, tmp3); Four intermediate image variables are added.

Dealing with API variations

SMIL and FREIA, being both mathematical morphology libraries, provide relatively close APIs: function names and parameters are similar, which eases the conversion. The remaining differences must nonetheless be taken care of.

Structuring elements

One example of an API variation between SMIL and FREIA is the structuring element data structure. A structuring element is a data structure describing a neighborhood for stencils. They are widely used in mathematical morphology operators.

In FREIA, structuring elements are boolean integer arrays and only take the first neighbors into account. Operating on a larger neighborhood amounts then to iterating several times over the operation. In SMIL, the corresponding data structure is more complex: it involves in particular a std::vec of neighbors and an integer size. When converting a SMIL morphological operator into FREIA, smiltofreia takes care of the size of the structuring element to generate a loop over the FREIA operator call. For instance, the following SMIL dilatation with a structuring element of size 5: Common-used structuring elements are stored in a separate smil-freia.h compatibility header as constants. Preprocessor macros are used to mimic the SMIL data structure while keeping track of the structuring element size; this allows our source-to-source compiler to fully forward-substitute these variables.

Altering FREIA

During the development of smiltofreia, we came to realize that some transformations would be eased by adapting directly the FREIA API. For example, part of the FREIA API implies that we always use a default structuring element, whereas the SMIL equivalent accepts arbitrary ones. Functions having the following signature freia_status freia_cipo_dilate(freia_data2d *imout, freia_data2d *imin, These new functions ease the generation of FREIA code from SMIL.

uint32_t size) { unsigned int i; int32_t square_strelt[9] = { 1, 1, 1, 1, 1, 1,
Another example is the smil.mask() function, which had no direct equivalent in FREIA prior to this work. A workaround combining two existing FREIA functions but adding temporary images would be easier to implement, although at the expense of the global performance.

Performance Evaluation

We evaluated our compilation chain using seven image processing FREIA applications taken from [START_REF] Coelho | API Compilation for Image Hardware Accelerators[END_REF], which we rewrote entirely in idiomatic SMIL C++, on the one hand, and SMIL Python, on the other hand. We are thus able to compare the performance of the output of our smiltofreia compiler to the original application.

We first compare the number of lines of code used for writing these seven applications in FREIA and in SMIL Python. The results are assembled in Table 1, which shows that SMIL applications are on average three times shorter than FREIA ones, mainly due to the concise syntax and the memory management model of Python. The SMIL C++ applications have roughly the same number of lines of code than their Python counterparts, but the C++ syntax is more complex and intrusive. We then compare the execution times of our seven applications, written in SMIL C++, SMIL Python and FREIA, and the impact of using smiltofreia to convert SMIL Python applications into FREIA. FREIA applications can also be further optimized by the source-to-source compiler PIPS. This optimized version is compared below to the non-optimized one. We executed these applications using the SMIL backend of FREIA on an Intel Sandy Bridge Core i7-3820 CPU. Figure 9 represents the simplified software used for this evaluation. All applications are in the end calling the SMIL library and are being executed on the same hardware. As shown in Figure 10, FREIA applications are tested with and without PIPS source-to-source optimizations. Execution times of original and smiltofreia-generated applications are similarly compared. The applications are executed with a fixed number of OpenMP threads equal to the number of physical cores of the current CPU, which has four of them. Input images are scaled to a 4K resolution of 3840 × 2160 to ensure correctly fed threads. The SMIL Python applications are converted to FREIA using the smiltofreia compiler and their execution time is measured as well (Column "Generated"). FREIA applications are executed with and without compile-time optimizations.

Apps

Hand-written FREIA app

Manual conversion

SMIL Python app

Apps

The resulting execution times of our seven applications are available in Table 2. This table represents the figures of the original FREIA applications, their optimized version using PIPS and their port on SMIL Python. Here, Column "SMIL" refers to both the C++ and Python applications; Column "Hand-written" is the original FREIA applications, which have been rewritten in SMIL and executed in their original form in Sub-column "init" or optimized by PIPS in Sub-column "+ opts". Similarly, Column "Generated" represents the output of our smiltofreia compiler. Two sub-columns, "init" and "+ opts", show original and optimized execution times. The three plots in Figure 11, Figure 12 and Figure 13 serve as a visual representation of the data in Table 2. Figure 11 compares the execution times of SMIL C++ and SMIL Python applications, and shows a minimal overhead, amounting to less than 2%, when the Python language is used. The Python wrapper has therefore little to no impact on the global performance of our applications. SMIL applications in Python are as fast as SMIL C++ ones, while benefiting from the Python syntax.

We then compare the execution times of our SMIL Python applications, before and after being converted to FREIA by our smiltofreia compiler. We also tested applying our PIPS optimizing compiler on the generated FREIA code. Results are displayed in Figure 12. The "anr999", "deblocking", "li-censePlate", and "toggle" applications yield similar performance before and after being converted into FREIA. Source-to-source optimizations performed by PIPS have a major impact on the execution times of the "anr999" and "li-censePlate" applications, especially by removing unnecessary copies between operations and merging identical computation sequences. The "antibio" and Relative execution time SMIL Python Generated FREIA Generated FREIA + opts Fig. 12: Comparison of the relative execution times of seven image processing applications written in SMIL Python, executed using the Python interpreter, then converted into FREIA and executed with and without compile-time optimizations "burner" FREIA applications are somewhat around 30% slower than their SMIL versions. This stems from the use of a peculiar mathematical morphology operator called geodesic reconstruct by closing, which has a coarse-grain implementation in SMIL, whereas in FREIA it is decomposed into several other simpler operators. The "retina" application is also affected by this issue. The SMIL implementation uses complex data structures, such as hierarchical queues, which are quite efficient on large images, as in the present case. Implementing algebraic optimizations [START_REF] Zory | Contribution à l'optimisation de programmes scientifiques[END_REF][START_REF] Zory | Using Algebraic Transformations to Optimize Expression Evaluation in Scientific Codes[END_REF] to detect this coarse-grain operator in a sequence of FREIA atomic operators and replace it by the corresponding SMIL call can help to reduce this slowdown. On average, these result show that FREIA generated code is about 10% slower than SMIL Python code, although applying PIPS optimizations can lead to 10% faster code.

Figure 13 compares the execution times of the original FREIA applications to those generated from Python by smiltofreia. Generated FREIA applications perform on average as well as original ones. As seen in the previous Figure, applying PIPS optimizations leads to increased performance in the "anr999" and the "licensePlate" applications in both cases, whereas the generated version of the "retina" application does not seem to benefit from it. This can be explained by the introduction of compatibility code for bridging the gap between SMIL and FREIA, which in this case slows down the generated code. To mitigate these slowdowns, a small speedup of the generated version of the "toggle" application can be linked to the use of newly introduced FREIA functions, such as freia_aipo_mask, which allow more direct calls to SMIL functions in the FREIA API. We show through these figures that

Relative execution time

Hand-written FREIA Hand-written FREIA + opts Generated FREIA Generated FREIA + opts Fig. 13: Comparison of the relative execution times of seven image processing applications written in SMIL Python and converted into FREIA, and genuine hand-written FREIA applications, executed with and without compile-time optimizations smiltofreia-generated FREIA applications perform very closely to original FREIA applications, with or without PIPS optimizations, the average execution times ratio amounting to less than 1% in both cases. Converting SMIL Python applications to FREIA is also a way to automatically port Python applications onto embedded accelerators dedicated to image processing. Thanks to FREIA portability, we executed our image processing applications onto two hardware accelerators implemented on FPGA: SPoC [START_REF] Clienti | A System On Chip Dedicated To Pipeline Neighborhood Processing For Mathematical Morphology[END_REF] and Terapix [START_REF] Bonnot | Definition and SIMD Implementation of a Multi-Processing Architecture Approach on FPGA[END_REF]. There is no Python interpreter available for these accelerators, nor any SMIL implementation, which prevent SMIL applications to be directly executed on these platforms. In Figure 14 and Figure 15, we compare the execution times of the original hand-written FREIA applications to the SMIL Python ones after being converted through smiltofreia. Raw results are also available in Table 3.

Specific hardware

Results show that generated FREIA code performs identically to handwritten code on these accelerators, except for the "deblocking" and "toggle" applications. The corresponding slowdown stems from the original conversion of these applications from FREIA to SMIL Python: a FREIA operator that was not implemented in SMIL has been replaced by a combination of two SMIL operators. smiltofreia does not yet look for such a combination to regenerate the original FREIA operator. Due to these two applications, smiltofreiagenerated code performs on average 4% slower on SPoC and 3% slower on Terapix.

We also studied the impact of PIPS optimizations and target-specific codegeneration in both cases. These optimizations are a bit less effective for smiltofreia-generated code than for hand-written FREIA. One of the reasons of this slowdown again comes from the original rewriting of FREIA applications to SMIL Python. We translated FREIA application functions into idiomatic Python, and returned the produced image pointers instead of passing them by reference, thus preventing PIPS from performing some useful operator ag-

Relative execution time

Hand-written FREIA Terapix Hand + opts Generated FREIA Terapix Gen + opts Fig. 15: Relative execution times of hand-written FREIA C and smiltofreiagenerated FREIA applications executed on the Terapix embedded accelerator, with and without PIPS optimizations gregation. These slowdowns amount to 20% for SPoC and 19% for Terapix, which is quite acceptable, considering the average speedups of 7.2× for SPoC and 1.8× for Terapix given by PIPS optimizations. Further improvements of smiltofreia-generated applications may be attainable by generating more idiomatic C code. These tables and plots show that SMIL applications easily benefit from our FREIA compilation toolchain with minimal performance impairment compared to hand-written code. What's more, SMIL applications can now directly target the whole set of FREIA hardware backends (FPGAs, manycore and GPUs) without modifying the input code. Improved performance can still be achievable in the current case by using PIPS not only to clean the generated FREIA applications, but also by regenerating aggregated SMIL C++ calls, hence getting rid of the FREIA API and the C wrapper intermediary layers.

Related Work

Python is a versatile general-purpose programming language especially used for fast application prototyping. However, the Python interpreter performance pales compared to native compiled languages such as C or C++. Other research projects use subsets of Python as inputs to accelerate applications on several hardware targets.

Cython [START_REF]Cython: C-Extensions for Python[END_REF], which we already described in subsection 3.2, is both an interfacing tool between Python and C and a Python-to-C compiler. Yet Cython output is overly complex and implements parts of the Python interpreter.

Pythran [START_REF] Guelton | Pythran: enabling static optimization of scientific Python programs[END_REF] is a Python-to-C++ compiler for scientific programs targeting multicore CPUs with SIMD extensions. Pythran generates C++ source code or shared libraries from Python code, which can be reused directly in a Python application.

Numba [START_REF] Siu Kwan Lam | Numba: A LLVMbased Python JIT Compiler[END_REF] is a Python-to-LLVM JIT compiler dedicated to accelerating Python code, but still needs the Python interpreter to work. Similarly, Parakeet [START_REF] Rubinsteyn | Parakeet: A Just-In-Time Parallel Accelerator for Python[END_REF] is a JIT compiler to parallelize Python code on CPUs or GPUs.

Theano [START_REF] Bergstra | Theano: a CPU and GPU Math Expression Compiler[END_REF] and Tensorflow [START_REF] Abadi | TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems[END_REF] are DSL compilers for Python linear algebra applications for deep learning which generate optimized C++ or CUDA. Image processing compilers such as Halide [START_REF] Ragan-Kelley | Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines[END_REF] and PolyMage [START_REF] Teja Mullapudi | PolyMage: Automatic Optimization for Image Processing Pipelines[END_REF] also aim at performing domain-specific optimizations while still offering ease of programming through high-level DSLs. While PolyMage is still limited to CPU execution, Halide is able to generate OpenCL and CUDA code for running onto GPUs.

Conclusion

We study in this paper a static to dynamic DSL compilation scheme that preserves programmability. As a use case, we developed a fully-functional implementation, called smiltofreia, that converts image processing applications written in a high-level DSL running on a small set of hardware targets to a lower-level DSL that supports a greater number of backends. Our proposed solution relies on transformations on an AST-like data structure of the original application for generating corresponding calls and variable declarations in the output language. Since the source DSL is embedded in Python, and the target DSL is embedded in C, typing and polymorphism have been taken care of. Experimental results on a set of seven image processing applications show that generated code is competitive with its input in terms of execution times. Moreover, additional target-specific optimization, such as these provided by the source-to-source compiler PIPS, can lead to improved performance for target DSL applications.

Fig. 1 :

 1 Fig. 1: Example of an image processing application: automatic detection of retina damage

1 import smilPython as smil 2 3 4 6 Fig. 2 :

 1362 Fig. 2: Morphological dilatation in SMIL

4 /

 4 / initializations...

7 *}Fig. 3 :

 73 Fig. 3: Morphological dilatation in FREIA (excerpt)

Fig. 4 :

 4 Fig. 4: Compiler toolchain diagram

Fig. 5 :Fig. 6 :

 56 Fig. 5: FST of smil.dilate(imin, imout)

Fig. 7 :Fig. 8 :

 78 Fig. 7: Actual C call to FREIA dilatation after Cython compilation

Algorithm 2 :

 2 smiltofreia RedBaron node transformation function Input: src -SMIL Python function FST Output: dst -corresponding FREIA C function /* recursive bottom-up code generation and typing */ 1 def generate_c(node, scope): (node.rightarg, scope);

  smil.dilate(imin, imout, smil.SquSE[START_REF]Is Python faster and lighter than C++?[END_REF]) is translated into the following FREIA code:#define e0 SMILTOFREIA_SQUSE #define e0_s 5 freia_cipo_dilate_generic_8c(imout, imin, e0, e0_s);

Fig. 10 :

 10 Fig. 10: Evaluation methodology

Fig. 11 :

 11 Fig. 11: Comparison of the relative execution times of seven image processing applications written in SMIL using the C++ and the Python API

Fig. 14 :

 14 Fig. 14: Relative execution times of hand-written FREIA C and smiltofreiagenerated FREIA applications executed on the SPoC embedded accelerator, with and without PIPS optimizations

  only use square structuring elements (a boolean array of nine ones), but of arbitrary size: internally, a loop around freia_aipo_dilate is used.Instead of adding additional constraints into smiltofreia inputs, we can alter and improve FREIA to support such cases. New functions have thus been added to FREIA to bring it closer to the SMIL API:

	1, 1, 1};
	freia_aipo_dilate_8c(imout, imin, square_strelt);
	for (i = 1; i < size; i++)
	freia_aipo_dilate_8c(imout, imout, square_strelt);
	return FREIA_OK;
	}
	void freia_cipo_dilate_generic_8c(freia_data2d *imout,
	freia_data2d *imin,
	const int32_t *se,
	uint32_t size);

Table 1 :

 1 Number of lines of SMIL and FREIA code for seven image processing applications

			#LoC	Gain
			SMIL FREIA
	anr999	23	88	3.8
	antibio	61	172	2.8
	burner	55	140	2.5
	deblocking	74	162	2.2
	licensePlate	37	202	5.5
	retina		40	133	3.3
	toggle		40	144	3.6
	GMEAN	44.4	144.7	3.2
	5.1 General-purpose CPU
				smiltofreia
	SMIL	SMIL			FREIA
	app.cpp	app.py			app.c
					applications
					runtimes
	SMIL Python		FREIA common
	Swig wrapper		runtime
	SMIL lib
	(C++, OpenMP)
					hardware
	Intel Sandy Bridge Core i7-3820
	4 cores, AVX
	Fig. 9: Compiler toolchain diagram

Table 2 :

 2 Execution times (ms) of seven image processing image applications written in SMIL (C++ and Python) and FREIA (Column "Hand-written").

		SMIL			FREIA
		C++ Python	Hand-written init + opts	Generated init + opts
	anr999	80.9	84.2	81.5	61.8	81.8	63.2
	antibio	2795	2800 3470	3540 3500	3500
	burner	1220	1210 1612	1630 1630	1585
	deblocking	828	852	864	866	860	861
	licensePlate	196	198	195	84.3	195	84.3
	retina	1010	1020 1110	964 1115	1105
	toggle	47.0	47.0	47.4	48.1	46.6	46.6

Table 3 :

 3 Execution times (s) of seven image processing image applications written in SMIL Python and FREIA (Column "Hand-written") and executed on the SPoC and Terapix image processing hardware accelerators. The SMIL Python applications are converted to FREIA using the smiltofreia compiler and their execution time is measured as well (Column "Generated"). All applications are executed with and without compile-time optimizations.

Acknowledgments: This work was funded by Investissements d'Avenir as part of the CAPACITES project.