-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nocrypto.0.5.0 illegal instruction #73
Comments
this seems to be a duplicate of #72, fixed in master (which now has configuration-time detection whether AES-NI is available or not). Could you please pin to master and report whether this works for you? |
compile time detection does not solve the issue for us, as we will always be compiling on a different system than where we deploy... |
@toolslive What is your scenario here? Where do you deploy to, and what capabilities do CPUs there have? How unacceptable is it for you to Asking, because this is currently a balancing act: while at some point dynamic detection will land, I want more exposure for this code before complicating it further. So we're stuck with a static decision. The current master unconditionally disables acceleration if you pass Ideally, we could export package-level configuration options to opam, and you could tweak your list of configuration variables and have the packages respect them, a scheme Gentoo linux has been using for years. But as it stands, there is no way to let a user directly influence compile-time options of packages through opam (other than pin-and-edit). So unless we start hacking around with virtual packages that denote your preference for CPU acceleration, This choice can then be either requiring people to manually opt in, or opt out of acceleration. I am trying to feel out the user base here and decide what makes more sense, and I guess it all boils down to how prevalent this scenario is, where the deployment machine lacks features the build machine has, and how inconvenient the current mechanisms of control we have are for the users. Feedback more than appreciated. I didn't release an update precisely to get a little more info about where we run and how often we break with the current scheme. |
typically what happens is that we build an executable that ends up in a debian or redhat package. so we would prefer something like this: // gcc extension, run when lib is loaded...
int have_sse_4_2 = 0;
void __cpu_detect(void) __attribute__((constructor));
void __cpu_detect(void) {
unsigned int a = 0, b = 0, c = 0, d = 0, func = 1;
int r = 0;
r = __get_cpuid(func, &a, &b, &c, &d);
if (r == 0) {
/* Lookup failed */
c = 0;
}
have_sse_4_2 = (c & bit_SSE4_2) != 0;
} and then dispatch based on the detected capabilities. |
You mean, a little like this? It's quite clear how to go about detecting features, the problem is that the dispatch phase complicates code paths and, as I said, sufficiently so that it will have to wait a little. The question still stands: it sounds like whatever you are doing is specific enough -- and certainly non-casual enough -- that the solution of pinning and editing |
|
I'm still trying to gauge how to proceed here. While it is possible to influence the build with configure flags, I'm not sure that the current state is good. I'm thinking of maybe disabling Leaving this open until hopefully some opinions pile up. 😄 |
What exactly do you mean with "the dispatch phase complicates code paths" ? |
Around five just for AES. I am working on an accelerated GCM which adds several more varying entry-points, and actually the OCaml code has to change depending on presence of From a different POV, just the argument order of C primitives has a significant impact (~20% as of several months ago) on the overall performance. I need to benchmark how much is lost if there is a dispatch on entry; probably not too much but I expect it to factor. Then obviously there is the fact that this is portable to ARM, which means that parts of dispatched-to code can be compiled in only conditionally. Obviously AES itself can indeed be solved by a few So right now, I would rather disable acceleration in default builds than hack dynamic detection in just so it kinda works. |
maybe the dispatch should not be on function level, but on module level. |
That was my idea, yeah. I wanted to have a few distinct bits of code that have different and feature-dependent code paths, then figure out how to neatly swap out modules for various alternatives. Just had a chat with @hannesm; he thinks we should optionally take |
I kind of dislike the implicitness of env vars. There may be a way to subvert opam's |
if you really want to pass a flag to opam via the env variabale, you can already do it. warning: it's ugly.
$ opam pin add toto . -n
$ OPAMVAR_FOO=foo opam install toto -v
[...]
+ echo "foo" (CWD=/Users/thomas/.opam/profuse/build/toto.0.1)
- foo The |
You can put things in that file and that will work. You can also put things in |
See http://opam.ocaml.org/doc/manual/dev-manual.html#sec40 and |
@samoht is this supposed to be generated by the build system so that packages can provide information about their configuration in the opam system for other packages to consult ? |
yup. but I guess you can use that to register some user preferences as well (eg. you can create a package |
Hm. If I add a line If I create a file I've been re-reading the relevant portion of the dev manual, but I can't seem to figure out the central question: are package variables a closed set? (opam 1.2.2) |
Humph, the manual is wrong. The correct path is |
ah, the location for config files was changed some time ago from Implementing |
ah, found it: ocaml/opam#1385 |
Thanks, makes much more sense now. 😄 This almost works. Problem 1: opam seems to own Wish: Problem 2: I can use the new var to optionally filter out an an argument, with Wish: |
There is the |
That looks about right, thanks! But the fact that I added 444e627 and plan to release it tomorrow. With that, users can Going forward, I would like to avoid polluting |
Global opam variable @toolslive @domsj |
I don't think that |
As I commented on the opam issue there should be a way to declare and document the variables, having a default value should be added to the list. But this discussion should be continued there. |
for us, that interim option is ok. |
@pqwy I have written a proposal there ocaml/opam#2247 your feedback is welcome. |
You can use |
Nocrypto detects CPU features at build time, instead of runtime. If the build machine is newer than the machine you install the binary on then it would crash with an illegal instruction on startup. See https://github.com/mirleft/ocaml-nocrypto#illegal-instructions and mirleft/ocaml-nocrypto#73 Since there is no runtime detection the only safe thing to do is to disable the use of these instructions always. Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com>
on a Quad-Core AMD Opteron 2350 we got:
so it's using instructions it shouldn't.
Also, it would be nice to have the detection at runtime, instead of at compile-time, as we often don't know where it will be deployed.
The text was updated successfully, but these errors were encountered: