Skip to content

Commit 2087ed5

Browse files
author
Luca Toniolo
committed
Deprecate uses_fp parameter in RTAPI and HAL APIs
All threads now unconditionally save and restore FPU/SSE state, making the uses_fp parameter obsolete. Rather than removing it from the API (which would break out-of-tree components), this commit deprecates it with a grace period: RTAPI: uses_fp parameter is accepted but ignored; FPU state is always saved in rtapi_task_new() regardless of the value passed. HAL: uses_fp parameter is accepted but ignored in hal_export_funct(), hal_export_functf(), and hal_create_thread(). All functions and threads are always marked as FP-capable internally. The addf FP compatibility check is removed since all threads are now FP-capable. halcompile: fp/nofp keywords in function declarations now emit a deprecation warning and are treated as fp (always return 1). The keywords will be removed in a future version. Remove fp/nofp from all in-tree .comp files, conv.comp.in template, and mkconv.sh generator. Remove fp1= from test .hal files. Out-of-tree .comp files will still parse but emit a deprecation warning. Documentation: API man pages, tutorials, and guides updated with deprecation notices. Removed references to FP thread restrictions that no longer apply. No API signatures changed — out-of-tree components continue to compile unchanged but will see warnings from halcompile if they use fp/nofp. Based on patch by BsAtHome. Ref: #3895
1 parent dbb1094 commit 2087ed5

Some content is hidden

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

75 files changed

+147
-142
lines changed

docs/src/hal/basic-hal.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ Owner CodeAddr Arg FP Users Name
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.
71+
72+
[NOTE]
73+
====
74+
The `FP` column and the `uses_fp` parameter are deprecated.
75+
All threads now unconditionally save and restore floating point state.
76+
The `fp`/`nofp` distinction will be removed in a future version.
77+
====
7378

7479
----
7580
$ halrun
@@ -78,14 +83,13 @@ halcmd: show thread
7883
Realtime Threads:
7984
Period FP Name ( Time, Max-Time )
8085
995976 YES servo-thread ( 0, 0 )
81-
55332 NO base-thread ( 0, 0 )
86+
55332 YES base-thread ( 0, 0 )
8287
----
8388

8489
- base-thread (the high-speed thread):
8590
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.
8791
- 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.
92+
This thread handles items that can tolerate a slower response, like the motion controller, ClassicLadder, and the motion command handler.
8993

9094
.addf Syntax and Example
9195
[source,{hal}]
@@ -94,9 +98,6 @@ addf <function> <thread>
9498
addf mux4.0 servo-thread
9599
----
96100

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

docs/src/hal/rtcomps.adoc

Lines changed: 5 additions & 5 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]]
@@ -638,7 +638,7 @@ They were changed to pins to allow control by other components.]
638638
(((lut5)))
639639
The `lut5` component is a 5 input logic component based on a look up table.
640640

641-
* `lut5` does not require a floating point thread.
641+
* `lut5` does not use floating point math.
642642

643643
.Loading `lut5`
644644
----

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: 8 additions & 8 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,15 @@ 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.
565+
566+
NOTE: The `fp1=` parameter is deprecated and ignored.
567+
All threads now unconditionally support floating point.
567568

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

736736
The last function, `stepgen.update-freq`, is responsible for doing
737737
scaling and some other calculations that need to be performed
@@ -754,13 +754,13 @@ halcmd: show thread
754754
Realtime Threads:
755755
Period FP Name ( Time, Max-Time )
756756
996980 YES slow ( 0, 0 )
757-
49849 NO fast ( 0, 0 )
757+
49849 YES fast ( 0, 0 )
758758
----
759759

760760
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.
761+
The first one, 'slow', runs every millisecond.
762762
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.
763+
The second thread is 'fast', which runs every 50 microseconds (µs).
764764
We will use it for `stepgen.make_pulses`.
765765
To connect the functions to the proper thread, we use the `addf` command.
766766
We specify the function first, followed by the thread.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ name::
1717
period::
1818
The interval, in nanoseconds, between iterations of the thread.
1919
uses_fp::
20-
Must be nonzero if a function which uses floating-point will be attached to this thread.
20+
Deprecated and ignored. All threads now unconditionally save and restore
21+
floating point state. This parameter will be removed in a future version.
2122

2223
== DESCRIPTION
2324

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ funct::
2121
arg::
2222
The argument to be passed as the first parameter of _funct_.
2323
uses_fp::
24-
Nonzero if the function uses floating-point operations, including
25-
assignment of floating point values with "=".
24+
Deprecated and ignored. All threads now unconditionally save and restore
25+
floating point state. This parameter will be removed in a future version.
2626
reentrant::
2727
If reentrant is non-zero, the function may be preempted and called again before the first call completes.
2828
Otherwise, it may only be added to one thread.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ arg::
2424
prio::
2525
A task priority value returned by *rtapi_prio_xxxx*
2626
uses_fp::
27-
A flag that tells the OS whether the task uses floating point or not.
27+
Deprecated and ignored. All tasks now unconditionally save and restore
28+
floating point state. This parameter will be removed in a future version.
2829
task_id::
2930
A task ID returned by a previous call to *rtapi_task_new*
3031

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ 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).
63+
NOTE: The *base_thread_fp* parameter is deprecated and ignored.
64+
All threads now unconditionally save and restore floating point state.
65+
This parameter will be removed in a future version.
6766

6867
These pins and parameters are created by the realtime *motmod* module.
6968
This module provides a HAL interface for LinuxCNC's motion planner.

src/hal/components/abs_s32.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pin out bit is_positive "TRUE if input is positive, FALSE if input is 0 or negat
2222
pin out bit is_negative "TRUE if input is negative, FALSE if input is 0 or positive";
2323

2424
option period no;
25-
function _ nofp;
25+
function _;
2626
license "GPL";
2727
author "Sebastian Kuzminsky";
2828
;;

src/hal/components/abs_s64.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pin out bit is_positive "true if input is positive, false if input is 0 or negat
2424
pin out bit is_negative "true if input is negative, false if input is 0 or positive";
2525

2626
option period no;
27-
function _ nofp;
27+
function _;
2828
license "GPL";
2929
author "ArcEye based on code from Sebastian Kuzminsky";
3030
;;

0 commit comments

Comments
 (0)