public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: ecos-patches@ecos.sourceware.org
Subject: [Bug 1001607] Cortex-M4F architectural Floating Point Support
Date: Wed, 20 Feb 2013 03:21:00 -0000	[thread overview]
Message-ID: <bug-1001607-104-sO6krt8mfv@http.bugs.ecos.sourceware.org/> (raw)
In-Reply-To: <bug-1001607-104@http.bugs.ecos.sourceware.org/>

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001607

--- Comment #57 from Jonathan Larmour <jifl@ecoscentric.com> ---
Hi Ilija,

(In reply to comment #53)
> (In reply to comment #52)
> > (In reply to comment #45)
> > >     - fpinttest.c renamed fpinttestf.c.
> > >     - Added fpinttestf1.c for testing of NONE context switching scheme, as
> > > it normally fails fpinttestf.c
> > 
> > In that case fpinttestf.c should use CYG_TEST_NA if it's using the NONE
> > context scheme - tests should do the right thing whatever the configuration.
> > 
> > So I suggest adding this to the tests in fpinttestf.c for when to be NA
> > (including in the CYG_TEST_NA call itself at the bottom):
> >  (!defined(CYGHWR_HAL_CORTEXM_FPU) || !defined(CYGHWR_HAL_CORTEXM_FPU_SWITCH_NONE))
> 
> I don't think we need the CYGHWR_HAL_CORTEXM_FPU test. On the other hand
> fprintestsf.c is included in fpinttestf1.c which overrides FP_THREADS_N.
> Therefore for the last condition I put:
> (!defined(CYGHWR_HAL_CORTEXM_FPU_SWITCH_NONE) || (FP_THREADS_N == 1))
> 
> FAOD: Since we want to move tests in kernel/tests, we don't have problem
> with mentioning CORTEXM macros, do we?

Well, we could abstract this out as a separate property using a test-specific
option in the kernel CDL. In eCoscentric we do something similar for the
except1/kexcept1 tests, although we've never got around to contributing that
yet. So instead we could have:
(!defined(CYGTST_KERNEL_SKIP_MULTI_THREAD_FP_TEST) || (FP_THREADS_N == 1))

Then in CYGHWR_HAL_CORTEXM_FPU_SWITCH, the cortex-m arch HAL can have:
requires { CYGHWR_HAL_CORTEXM_FPU_SWITCH_NONE implies
CYGTST_KERNEL_SKIP_MULTI_THREAD_FP_TEST }

I have some other comments on the patch for the tests:
- In the changelog, "floatn" -> "floating"

- fpinttestf1.c says it is fpinttestf.c at the top, and the mention of the NONE
switching scheme is a bit Cortex-M specific for something in the kernel. So
perhaps some more generic comments could be used instead, or at least qualify
it by saying it was written intended for the Cortex-M's NONE switching scheme,
but is worth testing elsewhere.

- fpinttestf2.c has the same issues, and also:
 - the RAM size test can be removed now that FP2_COUNT is fixed.
 - I think the stack sizes seem quite large. At the very least, they should
probably use CYGNUM_HAL_STACK_SIZE_TYPICAL as a starting point to allow for
variations between architectures.
 - The stacks should also be defined with CYGBLD_ATTRIB_ALIGN_MAX.
 - For generic, rather than cortex-m code, I think there needs to be a
CYGBLD_ATTRIB_NO_INLINE
 - Most places I've worked have coding standards that recommend againts this
sort of thing:
   while(ticks == alarm_ticks);
  Instead I'd recommend:
   while(ticks == alarm_ticks)
     CYG_EMPTY_STATEMENT;
 - In recalc(), you test sizeof(float) != sizeof(cyg_uint32), but the printed
message has 2*sizeof(cyg_uint32)

- Like the others, fpinttestf3.c also has the issue of mentioning the cortex-m
specific NONE switching scheme.
- Same issues with stack size+alignment, noinline, recalc.

- For thread_switch_fpu.cxx:
 - the stack size should be CYGNUM_HAL_STACK_SIZE_TYPICAL not
CYGNUM_HAL_STACK_SIZE_MINIMUM (I know, this is also a problem in tm_basic).
 - the stacks need aligned again
 - you can remove all the clock latency stuff.

> > (In reply to comment #50)
> > > 
> > > Here is a patch with CYGARC_CORTEXM_FPU_EXC_AUTOSAVE option removed.
> > > CYGARC_CORTEXM_FPU_EXC_AUTOSAVE still lives as a macro defined in
> > > fpv4_sp_d16.h.
> > 
> > Hmm, so I've now started wondering about saving the context in lazy mode as
> > well. You already set CYGARC_REG_FPU_FPCCR_ASPEN/LSPEN for lazy mode which
> > means the CPU will already be doing lazy stacking in interrupt/exception
> > handlers.
> > 
> > So in fact, can we just change the define at the top of fpv4_sp_d16.h to:
> > 
> > #if defined CYGHWR_HAL_CORTEXM_FPU_SWITCH_ALL || \
> >     defined CYGHWR_HAL_CORTEXM_FPU_SWITCH_LAZY
> > #define CYGARC_CORTEXM_FPU_EXC_AUTOSAVE
> > #endif
> > 
> > and then change the CYGHWR_HAL_CORTEXM_FPU_SWITCH_ALL test on line 158 to
> > also include LAZY, and then it might just work for lazy mode too? I can't
> > see anything else in the way.
> 
> Provided that that LAZY uses FPU enabled/disbled state in order to
> distinguish between _FP_ and _INT_ threads, suppose that _INT_ thread is
> interrupted by _FP_ ISR. Then Usage Fault VSR will enable FPU and FPU will
> remain enabled after ISR returns [in thread context], effectively converting
> the tread to _FP_. Gradually, this ISR "_FP_ missioner" ISR may convert all
> threads to _FP_ so we're not lazy any more.

Yes you're right of course. But I can't help feel it wouldn't be difficult to
fix this in the exception and interrupt vsrs - e.g. set
HAL_SAVEDREGISTERS_WITH_FPU as the saved register type if the FPU enabled bit
is set in FPU_CPACR on entry to the exception or interrupt VSR, and then ensure
the FPU is enabled/disabled accordingly before exit. I just get the feeling
this should be able to be solved with little overhead.

That said, I don't want to hold up this patch now because of any potential
improvement here.

> There are also other problems, related to variable ISR stack frame length,
> that are described in that comment #42 and/or comment #47.

I'm not sure those are big issues - or at least, there has to be an acceptance
that lazy mode can have a bit of overhead. But again, let's leave for now.

> [snip]
> 
> > 
> > BTW don't forget at some point to either tidy up the indentations in the
> > CDL, or let me know and I will do so after check-in - you've done enough
> > after all!
> 
> I take it that we are a step or less to check in :)

Yes! In fact I have no problems with the FP patch 130210 and as far as I'm
concerned that patch can be committed. However I do have an issue with your
changes for the code build flag which you added in comment #56, which is that
this will also prevent use of the DSP instructions by GCC I believe?

Also of course as mentioned above, we still need to work out the last few
niggles with those kernel tests.

> I am trying to keep the code tidy as we apporach end of the pipeline, but
> sometimes my editor tries to play smart and doesn't agree with me. I'll
> check it before check-in, but if you are not happy you are welcome to edit.

Yes that's fine, I'll get anything I see cleaned up, so don't worry about it
too much.

> Speaking of CDL cross check, I would ask you is to make language and clarity
> check on larger descrioptions, especially CYGHWR_HAL_CORTEXM_FPU_SWITCH.

In fact, I've got a willing lackey here (he'll hate me saying that ;-)) who
will be able to help clean up that and few other Cortex-M and, for that matter,
Kinetis related CDL. I'll put some patches in bugzilla soon for you to look at.

Jifl

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2013-02-20  3:21 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-03 12:57 [Bug 1001607] New: " bugzilla-daemon
2012-06-03 12:58 ` [Bug 1001607] " bugzilla-daemon
2012-06-03 12:59 ` bugzilla-daemon
2012-06-03 13:04 ` bugzilla-daemon
2012-06-03 13:05 ` bugzilla-daemon
2012-06-03 13:06 ` bugzilla-daemon
2012-06-03 14:22 ` bugzilla-daemon
2012-06-03 16:22 ` bugzilla-daemon
2012-06-06  6:33 ` bugzilla-daemon
2012-06-10 20:56 ` bugzilla-daemon
2012-06-22  4:56 ` bugzilla-daemon
2012-06-24 15:01 ` bugzilla-daemon
2012-06-28  7:41 ` bugzilla-daemon
2012-07-01  4:23 ` bugzilla-daemon
2012-07-08 16:51 ` bugzilla-daemon
2012-07-08 16:52 ` bugzilla-daemon
2012-07-08 16:53 ` bugzilla-daemon
2012-08-07  5:56 ` bugzilla-daemon
2012-08-07  5:57 ` bugzilla-daemon
2012-08-08 16:49 ` bugzilla-daemon
2012-08-08 17:14 ` bugzilla-daemon
2012-08-08 18:01 ` bugzilla-daemon
2012-08-08 19:28 ` bugzilla-daemon
2012-08-09  4:03 ` bugzilla-daemon
2012-08-09 10:12 ` bugzilla-daemon
2012-08-10 18:09 ` bugzilla-daemon
2012-08-10 18:14 ` bugzilla-daemon
2012-08-12 11:05 ` bugzilla-daemon
2012-08-29 19:34 ` bugzilla-daemon
2012-08-29 19:36 ` bugzilla-daemon
2012-08-29 19:37 ` bugzilla-daemon
2012-08-31 18:40 ` bugzilla-daemon
2012-08-31 18:42 ` bugzilla-daemon
2012-10-09 19:33 ` bugzilla-daemon
2012-11-06 20:54 ` bugzilla-daemon
2012-11-06 20:56 ` bugzilla-daemon
2012-11-06 20:57 ` bugzilla-daemon
2012-12-02 20:15 ` bugzilla-daemon
2012-12-02 20:18 ` bugzilla-daemon
2012-12-02 20:20 ` bugzilla-daemon
2012-12-02 20:21 ` bugzilla-daemon
2012-12-13  5:37 ` bugzilla-daemon
2012-12-16 15:51 ` bugzilla-daemon
2012-12-17  4:02 ` bugzilla-daemon
2012-12-17 14:05 ` bugzilla-daemon
2012-12-17 15:30 ` bugzilla-daemon
2012-12-21 13:42 ` bugzilla-daemon
2012-12-21 13:53 ` bugzilla-daemon
2013-02-06 21:29 ` bugzilla-daemon
2013-02-06 23:02 ` bugzilla-daemon
2013-02-06 23:08 ` bugzilla-daemon
2013-02-07  9:47 ` bugzilla-daemon
2013-02-07 21:52 ` bugzilla-daemon
2013-02-07 21:57 ` bugzilla-daemon
2013-02-07 21:59 ` bugzilla-daemon
2013-02-07 22:00 ` bugzilla-daemon
2013-02-09  2:08 ` bugzilla-daemon
2013-02-10 12:33 ` bugzilla-daemon
2013-02-10 17:30 ` bugzilla-daemon
2013-02-10 17:34 ` bugzilla-daemon
2013-02-16 14:34 ` bugzilla-daemon
2013-02-20  3:21 ` bugzilla-daemon [this message]
2013-03-07  0:16 ` bugzilla-daemon
2013-03-07  0:17 ` bugzilla-daemon
2013-03-07  0:18 ` bugzilla-daemon
2013-03-07  0:19 ` bugzilla-daemon
2013-03-07  1:46 ` bugzilla-daemon
2013-03-08 15:09 ` bugzilla-daemon
2013-03-09 22:49 ` bugzilla-daemon
2013-03-12 22:42 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-1001607-104-sO6krt8mfv@http.bugs.ecos.sourceware.org/ \
    --to=bugzilla-daemon@bugs.ecos.sourceware.org \
    --cc=ecos-patches@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).