Open Bug 458480 Opened 18 years ago Updated 4 years ago

SSE2 instructions for bignum are not implemented on Solaris 32-bit

Categories

(NSS :: Libraries, enhancement, P2)

3.12
x86
Solaris
enhancement

Tracking

(Not tracked)

People

(Reporter: julien.pierre, Unassigned)

Details

(Whiteboard: FIPS)

Attachments

(1 file)

Support for these instructions was added in bug 326482 . Unfortunately, it was implemented in such a way that does not allow the code to be easily reused on other x86 platforms, most notably Solaris. Here are the existing issues : 1) the assembly code in mpi_x86.s keeps calling s_mpi_is_sse2 every time there is a computation . This is inefficient. Support for SSE2 should only need to be tested once when softoken loads freebl. 2) the SSE2 code lives in the same source assembler source file as the non-SSE2 (regular x86 multiply) code. On Solaris, binaries are marked with flags that state what instruction set the machine needs. They will not load if the local machine does not support them. The only solution to getting SSE2 support to work on Solaris would be to separate the SSE2 code into another assembler file, which would be linked into a separate freebl library. The loader should then take on the job of calling s_mpi_sse2 only once, and selecting the proper freebl shared library to load. I believe this technical solution is compatible with every x86 operating system that NSS currently supports, including Linux, Win32, Solaris x86, and MacOS, not to mention other less popular x86 platforms. I would propose that we move in the direction of having 2 different freebl for regular x86 and x86/SSE2 for all our primary platforms. This would keep things consistent and more maintainable than having some platforms where 2 implementations are merged in one shared library, and others where they are in 2 separate shared libraries.
Whiteboard: FIPS
> On Solaris, binaries are marked with flags that state what instruction set the > machine needs. They will not load if the local machine does not support them. That's true, but there's a pretty simple workaround. NSS used that for YEARS before it became legal to put NSS into shared libraries. I think there needs to be more than one function (or one source file) that differs before making yet another different shared lib. > The only solution to getting SSE2 support to work on Solaris would be to > separate the SSE2 code into another assembler file, which would be linked > into a separate freebl library. No, that's not the ONLY solution. It is *A* solution. If we get a LOT of code that works differently on one CPU than another, then it may be worthwhile to make a separate shared lib. But for one source file, I wouldn't bother.
Actually we don't call s_mpi_is_see2 on each call. We call it once per 'load' of freebl. the results is stored in the 'is_sse' variable. After that there is either one conditional jmp in the non sse case and 2 in the sse case. Both jumps are branch prediction friendly. I was unable to measure the performance difference between having the jumps and not having them. Basically the cost of the multiply loop itself greatly swamps the cost of the jmp instruction. When I initially added the code I evaluated the overhead of going to multiple binaries in Linux. The benefits (which were minimal) did not outway the costs. I think the equation is different for Solaris, but solaris already has it's own assembler file for this code. bob
Looking in my source tree I found an mpi_sse2.s assembler file which I was using when I first developed the sse2 code. Since I did not use that file in the final, it was not checked in, but I still have it in my source tree. As it may be useful in the solaris work, I'll attach it as an example to this bug. I don't know the state it was in when I completed the work (at one time it was working, but there may be some bit rot). bob
Attached file SSE2 .s file —
Nelson, Re: comment 1, if you are referring to misflagging binaries with the wrong instruction set, it *may* work for some cases, but I would call that a hack and not a solution. I think we should strive to write and build code the way it's recommended for our platform. There may be technical issues with trying to change the binary flags and pretend that our library doesn't use SSE2 when it contains SSE2 instructions. Doing that worked on Sparc for VIS because there were no extra VIS registers. VIS reused the Ultrasparc floating point registers. So, the context switches were always handled properly by the OS. I'm not sure if this will be the case on x86 with SSE2, since there are actual separate registers. It's conceivable that if the executable and no other library uses SSE2 instructions in a process, that the context switch by the OS would not push and pop those registers, as an optimization. I haven't looked at the Solaris implementation to see if that's the case or not. Even if it does push and pop all CPU registers today for all context switches regardless of binary flags, I think that's an implementation detail of Solaris that we should not be depending on. Bob, Re: comment 2, I hadn't realized that you had an optimization in there. I guess you still have one extra call and jmp in there for each computation, but I agree with you that it's not a big performance hit. Solaris does have its own assembler file, but it doesn't contain SSE2 instructions, only the regular multiply stuff. Thanks for the contribution of the other source file.
Blocks: FIPS2008
Assignee: nobody → julien.pierre.boogz
OS: All → Solaris
Summary: SSE2 instructions for bignum are implemented only on Linux 32-bit → SSE2 instructions for bignum are not implemented on Solaris 32-bit
Severity: normal → enhancement
assigning to Bob since Julien is on leave.
Assignee: julien.pierre.boogz → rrelyea
julien's back so reassign bug back to him. also removed from FIPS tracking bug.
Assignee: rrelyea → julien.pierre.boogz
No longer blocks: FIPS2008
Not for 3.12.4, but I would like to get this in eventually.
Priority: -- → P2
Target Milestone: --- → 3.13
Why not for 3.12.4? Is there a better target than a FIPS target for this? Or is this because of insistence upon filter/filtee libraries?
Nelson, We have multiple priorities and not enough time to get everything in for 3.12.4 . I just can't get this and the CRL work done in the next two weeks. Especially not if this has to be implemented through filter/filtee libraries. If we don't have that requirement, then I think it will be a lot easier, but I still don't think there is enough time to do it in the next 2 weeks even just adding a separate lib and changing the loader on solaris x86. I have seen how hard it was to make changes/get them reviewed/tested that didn't involve a new shared library (whether it's a new filter library, or new freebl shared lib).
Assignee: julien.pierre.boogz → nobody
Target Milestone: 3.13 → ---
Hardware: All → x86
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: