Skip to content

Commit 9486d25

Browse files
author
Luca Toniolo
committed
Remove uses_fp parameter from RTAPI and HAL APIs
Complete removal of the uses_fp parameter for 2.10. All threads now unconditionally save and restore FPU/SSE state. RTAPI: remove uses_fp from rtapi_task_new(), remove RTAPI_NO_FP and RTAPI_USES_FP constants, hardcode FPU save in rt_task_init_cpuid. HAL: remove uses_fp from hal_export_funct(), hal_export_functf(), hal_create_thread(). Remove uses_fp field from hal_funct_t and hal_thread_t structs. Remove addf FP compatibility check. Remove FP column from halcmd and halrmt display. Components: remove uses_fp argument from all hal_export_funct and hal_export_functf call sites. Remove base_thread_fp from motion module, fp1/fp2/fp3 from threads component. halcompile: remove OptFP grammar rule, fp/nofp parsing, and fp-related code generation and documentation output. Remove fp/nofp from all in-tree .comp files, conv.comp.in and mkconv.sh. Documentation: remove uses_fp from API man pages, remove FP thread references from tutorials and guides. Out-of-tree components must be updated to the new API signatures. Ref: #3895
1 parent c760c1b commit 9486d25

File tree

118 files changed

+228
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+228
-301
lines changed

docs/src/hal/basic-hal.adoc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,27 @@ $ halrun
6262
halcmd: loadrt or2
6363
halcmd: show function
6464
Exported Functions:
65-
Owner CodeAddr Arg FP Users Name
66-
00004 f8bc5000 f8f950c8 NO 0 or2.0
65+
Owner CodeAddr Arg Users Name
66+
00004 f8bc5000 f8f950c8 0 or2.0
6767
----
6868

6969
You have to add a function from a HAL real time component to a thread to get the function to update at the rate of the thread.
7070
Usually there are two threads as shown in this example.
71-
Some components use floating point math and must be added to a thread that supports floating point math.
72-
The `FP` indicates if floating point math is supported in that thread.
7371

7472
----
7573
$ halrun
7674
halcmd: loadrt motmod base_period_nsec=55555 servo_period_nsec=1000000 num_joints=3
7775
halcmd: show thread
7876
Realtime Threads:
79-
Period FP Name ( Time, Max-Time )
80-
995976 YES servo-thread ( 0, 0 )
81-
55332 NO base-thread ( 0, 0 )
77+
Period Name ( Time, Max-Time )
78+
995976 servo-thread ( 0, 0 )
79+
55332 base-thread ( 0, 0 )
8280
----
8381

8482
- base-thread (the high-speed thread):
8583
This thread handles items that need a fast response, like making step pulses, and reading and writing the parallel port.
86-
Does not support floating point math.
8784
- servo-thread (the slow-speed thread):
88-
This thread handles items that can tolerate a slower response, like the motion controller, ClassicLadder, and the motion command handler and supports floating point math.
85+
This thread handles items that can tolerate a slower response, like the motion controller, ClassicLadder, and the motion command handler.
8986

9087
.addf Syntax and Example
9188
[source,{hal}]
@@ -94,9 +91,6 @@ addf <function> <thread>
9491
addf mux4.0 servo-thread
9592
----
9693

97-
[NOTE]
98-
If the component requires a floating point thread that is usually the slower servo-thread.
99-
10094
[[sub:hal-loadusr]]
10195
=== loadusr
10296

docs/src/hal/rtcomps.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ image::images/stepgen-type11-14.png["Step Types: Five-Phase",align="center"]
162162
The component exports three functions.
163163
Each function acts on all of the step pulse generators - running different generators in different threads is not supported.
164164

165-
* (funct) `stepgen.make-pulses` - High speed function to generate and count pulses (no floating point).
165+
* (funct) `stepgen.make-pulses` - High speed function to generate and count pulses.
166166
* (funct) `stepgen.update-freq` - Low speed function does position to velocity conversion, scaling and limiting.
167167
* (funct) `stepgen.capture-position` - Low speed function for feedback, updates latches and scales position.
168168

@@ -258,7 +258,7 @@ Each PWM generator will also have some of these pins, depending on the output ty
258258

259259
The component exports two functions. Each function acts on all of the PWM generators - running different generators in different threads is not supported.
260260

261-
* (funct) `pwmgen.make-pulses` - High speed function to generate PWM waveforms (no floating point).
261+
* (funct) `pwmgen.make-pulses` - High speed function to generate PWM waveforms.
262262
The high speed function `pwmgen.make-pulses` should be run in the base (fastest) thread, from 10 to 50&#8239;µs depending on the capabilities of the computer.
263263
That thread's period determines the maximum PWM carrier frequency, as well as the resolution of the PWM or PDM signals.
264264
If the base thread is 50,000&#8239;ns then every 50&#8239;µs the module decides if it is time to change the state of the output.
@@ -361,7 +361,7 @@ halcmd: unloadrt encoder
361361
The component exports two functions.
362362
Each function acts on all of the encoder counters - running different counters in different threads is not supported.
363363

364-
* (funct) `encoder.update-counters` - High speed function to count pulses (no floating point).
364+
* (funct) `encoder.update-counters` - High speed function to count pulses.
365365
* (funct) `encoder.capture-position` - Low speed function to update latches and scale position.
366366

367367
[[sec:pid]]
@@ -515,7 +515,7 @@ Most encoder counters will count four times during one complete cycle.
515515

516516
The component exports two functions. Each function affects all simulated encoders.
517517

518-
* (funct) `sim-encoder.make-pulses` - High speed function to generate quadrature pulses (no floating point).
518+
* (funct) `sim-encoder.make-pulses` - High speed function to generate quadrature pulses.
519519
* (funct) `sim-encoder.update-speed` - Low speed function to read `.speed`, do scaling, and set up `.make-pulses`.
520520

521521
[[sec:debounce]]

docs/src/hal/tools.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ or
245245
2. If no pinname is specified, default is: `motion-command-handler.time`.
246246
3. This app may be opened for 5 pins.
247247
4. Pintypes float, s32, u32, bit are supported.
248-
5. The pin must be associated with a thread supporting floating point.
249-
For a base thread, this may require using `loadrt motmod ... base_thread_fp=1` .
248+
5. The pin must be associated with a realtime thread.
250249

251250
.hal-histogram Window
252251
image::images/hal-histogram.png["hal-histogram Window"]

docs/src/hal/tutorial.adoc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ Owner CodeAddr Arg FP Users Name
213213
----
214214

215215
The siggen component exported a single function.
216-
It requires floating point.
217216
It is not currently linked to any threads, so 'users' is
218217
zero footnote:[CodeAddr and Arg fields were used during development and
219218
should probably disappear.].
@@ -241,7 +240,7 @@ Realtime Threads:
241240

242241
It did. The period is not exactly 1,000,000 ns because of hardware
243242
limitations, but we have a thread that runs at approximately the
244-
correct rate, and which can handle floating point functions.
243+
correct rate.
245244
The next step is to connect the function to the thread:
246245

247246
.Add Function
@@ -557,13 +556,12 @@ component.
557556
halrun
558557
halcmd: loadrt stepgen step_type=0,0 ctrl_type=v,v
559558
halcmd: loadrt siggen
560-
halcmd: loadrt threads name1=fast fp1=0 period1=50000 name2=slow period2=1000000
559+
halcmd: loadrt threads name1=fast period1=50000 name2=slow period2=1000000
561560
----
562561

563562
The first command loads two step generators, both configured to generate stepping type 0.
564563
The second command loads our old friend siggen, and the third one creates two threads,
565564
a fast one with a period of 50 microseconds (µs) and a slow one with a period of 1 millisecond (ms).
566-
The fast thread doesn't support floating point functions.
567565

568566
As before, we can use `halcmd show` to take a look at the HAL.
569567
This time we have a lot more pins and parameters than before:
@@ -731,7 +729,6 @@ is time to take a step, and if so sets the outputs accordingly.
731729
For smooth step pulses, it should run as frequently as possible.
732730
Because it needs to run so fast, 'make_pulses'
733731
is highly optimized and performs only a few calculations.
734-
Unlike the others, it does not need floating point math.
735732

736733
The last function, `stepgen.update-freq`, is responsible for doing
737734
scaling and some other calculations that need to be performed
@@ -752,15 +749,15 @@ Let's see what threads we have available.
752749
halcmd: show thread
753750
754751
Realtime Threads:
755-
Period FP Name ( Time, Max-Time )
756-
996980 YES slow ( 0, 0 )
757-
49849 NO fast ( 0, 0 )
752+
Period Name ( Time, Max-Time )
753+
996980 slow ( 0, 0 )
754+
49849 fast ( 0, 0 )
758755
----
759756

760757
The two threads were created when we loaded `threads`.
761-
The first one, 'slow', runs every millisecond, and is capable of running floating point functions.
758+
The first one, 'slow', runs every millisecond.
762759
We will use it for `siggen.0.update` and `stepgen.update_freq`.
763-
The second thread is 'fast', which runs every 50 microseconds (µs), and does not support floating point.
760+
The second thread is 'fast', which runs every 50 microseconds (µs).
764761
We will use it for `stepgen.make_pulses`.
765762
To connect the functions to the proper thread, we use the `addf` command.
766763
We specify the function first, followed by the thread.

docs/src/man/man3/hal_create_thread.3.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ hal_create_thread - Create a HAL thread
66

77
== SYNTAX
88

9-
int hal_create_thread(const char* _name_, unsigned long _period_, int _uses_fp_)
9+
int hal_create_thread(const char* _name_, unsigned long _period_)
1010

1111
int hal_thread_delete(const char* _name_)
1212

@@ -16,8 +16,6 @@ name::
1616
The name of the thread.
1717
period::
1818
The interval, in nanoseconds, between iterations of the thread.
19-
uses_fp::
20-
Must be nonzero if a function which uses floating-point will be attached to this thread.
2119

2220
== DESCRIPTION
2321

docs/src/man/man3/hal_export_funct.3.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ hal_export_funct, hal_export_functf - create a realtime function callable from a
1010

1111
typedef void(*hal_funct_t)(void* _arg_, long _period_)
1212

13-
int hal_export_funct(const char* _name_, hal_funct_t _funct_, void* _arg_, int _uses_fp_, int _reentrant_, int _comp_id_)
13+
int hal_export_funct(const char* _name_, hal_funct_t _funct_, void* _arg_, int _reentrant_, int _comp_id_)
1414

1515
== ARGUMENTS
1616

@@ -20,9 +20,6 @@ funct::
2020
The pointer to the function.
2121
arg::
2222
The argument to be passed as the first parameter of _funct_.
23-
uses_fp::
24-
Nonzero if the function uses floating-point operations, including
25-
assignment of floating point values with "=".
2623
reentrant::
2724
If reentrant is non-zero, the function may be preempted and called again before the first call completes.
2825
Otherwise, it may only be added to one thread.

docs/src/man/man3/rtapi_task_new.3.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rtapi_task_new, rtapi_task_delete - create a realtime task
1111
[source,c]
1212
----
1313
int rtapi_task_new(void (*_taskcode_)(void*), void *_arg_, int _prio_,
14-
unsigned long _stacksize_, int _uses_fp_);
14+
unsigned long _stacksize_);
1515
int rtapi_task_delete(int _task_id_);
1616
----
1717

@@ -23,8 +23,6 @@ arg::
2323
An argument to be passed to the _taskcode_ function when the task is started
2424
prio::
2525
A task priority value returned by *rtapi_prio_xxxx*
26-
uses_fp::
27-
A flag that tells the OS whether the task uses floating point or not.
2826
task_id::
2927
A task ID returned by a previous call to *rtapi_task_new*
3028

docs/src/man/man9/motion.9.adoc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ motion, axis - accepts NML motion commands, interacts with HAL in realtime
66

77
== SYNOPSIS
88

9-
**loadrt motmod** [**base_period_nsec=**_period_] [**base_thread_fp=**_0 or 1_] [**servo_period_nsec=**_period_] [**traj_period_nsec=**_period_] [**num_joints=**_[1-16]_] [**num_dio=**_[1-64]_ | **names_dout=**_name_[,...] **names_din=**_name_[,...]] [**num_aio=**_[1-64]_ | **names_aout=**_name_[,...] __names_ain=_*_name_[,...]] [**num_misc_error=**_[0-64]_] [**num_spindles=**_[1-8]_] [**unlock_joints_mask=**_jointmask_] [**num_extrajoints=**_[0-16]_]
9+
**loadrt motmod** [**base_period_nsec=**_period_] [**servo_period_nsec=**_period_] [**traj_period_nsec=**_period_] [**num_joints=**_[1-16]_] [**num_dio=**_[1-64]_ | **names_dout=**_name_[,...] **names_din=**_name_[,...]] [**num_aio=**_[1-64]_ | **names_aout=**_name_[,...] __names_ain=_*_name_[,...]] [**num_misc_error=**_[0-64]_] [**num_spindles=**_[1-8]_] [**unlock_joints_mask=**_jointmask_] [**num_extrajoints=**_[0-16]_]
1010

1111
The limits for the following items are compile-time settings:
1212

@@ -60,11 +60,6 @@ the motion-controller function.
6060

6161
== DESCRIPTION
6262

63-
By default, the base thread does not support floating point. Software
64-
stepping, software encoder counting, and software pwm do not use floating point.
65-
*base_thread_fp* can be used to enable floating point in
66-
the base thread (for example for brushless DC motor control).
67-
6863
These pins and parameters are created by the realtime *motmod* module.
6964
This module provides a HAL interface for LinuxCNC's motion planner.
7065
Basically *motmod* takes in a list of waypoints and generates a nice

src/emc/motion/motion.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ static int key = DEFAULT_SHMEM_KEY; /* the shared memory key, default value */
4545
RTAPI_MP_INT(key, "shared memory key");
4646
static long base_period_nsec = 0; /* fastest thread period */
4747
RTAPI_MP_LONG(base_period_nsec, "fastest thread period (nsecs)");
48-
int base_thread_fp = 0; /* default is no floating point in base thread */
49-
RTAPI_MP_INT(base_thread_fp, "floating point in base thread?");
5048
static long servo_period_nsec = 1000000; /* servo thread period */
5149
RTAPI_MP_LONG(servo_period_nsec, "servo thread period (nsecs)");
5250
static long traj_period_nsec = 0; /* trajectory planner period */
@@ -1006,15 +1004,15 @@ static int init_threads(void)
10061004
/* create HAL threads for each period */
10071005
/* only create base thread if it is faster than servo thread */
10081006
if (servo_base_ratio > 1) {
1009-
retval = hal_create_thread("base-thread", base_period_nsec, base_thread_fp);
1007+
retval = hal_create_thread("base-thread", base_period_nsec);
10101008
if (retval < 0) {
10111009
rtapi_print_msg(RTAPI_MSG_ERR,
10121010
"MOTION: failed to create %ld nsec base thread\n",
10131011
base_period_nsec);
10141012
return -1;
10151013
}
10161014
}
1017-
retval = hal_create_thread("servo-thread", servo_period_nsec, 1);
1015+
retval = hal_create_thread("servo-thread", servo_period_nsec);
10181016
if (retval < 0) {
10191017
rtapi_print_msg(RTAPI_MSG_ERR,
10201018
"MOTION: failed to create %ld nsec servo thread\n",
@@ -1023,14 +1021,14 @@ static int init_threads(void)
10231021
}
10241022
/* export realtime functions that do the real work */
10251023
retval = hal_export_funct("motion-controller", emcmotController, 0 /* arg
1026-
*/ , 1 /* uses_fp */ , 0 /* reentrant */ , mot_comp_id);
1024+
*/ , 0 /* reentrant */ , mot_comp_id);
10271025
if (retval < 0) {
10281026
rtapi_print_msg(RTAPI_MSG_ERR,
10291027
"MOTION: failed to export controller function\n");
10301028
return -1;
10311029
}
10321030
retval = hal_export_funct("motion-command-handler", emcmotCommandHandler, 0 /* arg
1033-
*/ , 1 /* uses_fp */ , 0 /* reentrant */ , mot_comp_id);
1031+
*/ , 0 /* reentrant */ , mot_comp_id);
10341032
if (retval < 0) {
10351033
rtapi_print_msg(RTAPI_MSG_ERR,
10361034
"MOTION: failed to export command handler function\n");
@@ -1041,8 +1039,7 @@ static int init_threads(void)
10411039
/*! \todo FIXME - currently the traj planner is called from the controller */
10421040
/* eventually it will be a separate function */
10431041
retval = hal_export_funct("motion-traj-planner", emcmotTrajPlanner, 0 /* arg
1044-
*/ , 1 /* uses_fp */ ,
1045-
0 /* reentrant */ , mot_comp_id);
1042+
*/ , 0 /* reentrant */ , mot_comp_id);
10461043
if (retval < 0) {
10471044
rtapi_print_msg(RTAPI_MSG_ERR,
10481045
"MOTION: failed to export traj planner function\n");

src/hal/classicladder/module_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int rtapi_app_main(void) {
178178

179179
rtapi_print("creating ladder-state\n");
180180

181-
result = hal_export_funct("classicladder.0.refresh",hal_task,0,1, 0, compId);
181+
result = hal_export_funct("classicladder.0.refresh",hal_task,0, 0, compId);
182182
if(result < 0) {
183183
error:
184184
hal_exit(compId);

0 commit comments

Comments
 (0)