fx | A dependency injection based application framework for Go | Dependency Injection library
kandi X-RAY | fx Summary
kandi X-RAY | fx Summary
An application framework for Go that:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fx
fx Key Features
fx Examples and Code Snippets
Community Discussions
Trending Discussions on fx
QUESTION
I'm trying to make sure gcc vectorizes my loops. It turns out, that by using -march=znver1
(or -march=native
) gcc skips some loops even though they can be vectorized. Why does this happen?
In this code, the second loop, which multiplies each element by a scalar is not vectorised:
...ANSWER
Answered 2022-Apr-10 at 02:47The default -mtune=generic
has -mprefer-vector-width=256
, and -mavx2
doesn't change that.
znver1 implies -mprefer-vector-width=128
, because that's all the native width of the HW. An instruction using 32-byte YMM vectors decodes to at least 2 uops, more if it's a lane-crossing shuffle. For simple vertical SIMD like this, 32-byte vectors would be ok; the pipeline handles 2-uop instructions efficiently. (And I think is 6 uops wide but only 5 instructions wide, so max front-end throughput isn't available using only 1-uop instructions). But when vectorization would require shuffling, e.g. with arrays of different element widths, GCC code-gen can get messier with 256-bit or wider.
And vmovdqa ymm0, ymm1
mov-elimination only works on the low 128-bit half on Zen1. Also, normally using 256-bit vectors would imply one should use vzeroupper
afterwards, to avoid performance problems on other CPUs (but not Zen1).
I don't know how Zen1 handles misaligned 32-byte loads/stores where each 16-byte half is aligned but in separate cache lines. If that performs well, GCC might want to consider increasing the znver1 -mprefer-vector-width
to 256. But wider vectors means more cleanup code if the size isn't known to be a multiple of the vector width.
Ideally GCC would be able to detect easy cases like this and use 256-bit vectors there. (Pure vertical, no mixing of element widths, constant size that's am multiple of 32 bytes.) At least on CPUs where that's fine: znver1, but not bdver2 for example where 256-bit stores are always slow due to a CPU design bug.
You can see the result of this choice in the way it vectorizes your first loop, the memset-like loop, with a vmovdqu [rdx], xmm0
. https://godbolt.org/z/E5Tq7Gfzc
So given that GCC has decided to only use 128-bit vectors, which can only hold two uint64_t
elements, it (rightly or wrongly) decides it wouldn't be worth using vpsllq
/ vpaddd
to implement qword *5
as (v<<2) + v
, vs. doing it with integer in one LEA instruction.
Almost certainly wrongly in this case, since it still requires a separate load and store for every element or pair of elements. (And loop overhead since GCC's default is not to unroll except with PGO, -fprofile-use
. SIMD is like loop unrolling, especially on a CPU that handles 256-bit vectors as 2 separate uops.)
I'm not sure exactly what GCC means by "not vectorized: unsupported data-type". x86 doesn't have a SIMD uint64_t
multiply instruction until AVX-512, so perhaps GCC assigns it a cost based on the general case of having to emulate it with multiple 32x32 => 64-bit pmuludq
instructions and a bunch of shuffles. And it's only after it gets over that hump that it realizes that it's actually quite cheap for a constant like 5
with only 2 set bits?
That would explain GCC's decision-making process here, but I'm not sure it's exactly the right explanation. Still, these kinds of factors are what happen in a complex piece of machinery like a compiler. A skilled human can easily make smarter choices, but compilers just do sequences of optimization passes that don't always consider the big picture and all the details at the same time.
-mprefer-vector-width=256
doesn't help:
Not vectorizing uint64_t *= 5
seems to be a GCC9 regression
(The benchmarks in the question confirm that an actual Zen1 CPU gets a nearly 2x speedup, as expected from doing 2x uint64 in 6 uops vs. 1x in 5 uops with scalar. Or 4x uint64_t in 10 uops with 256-bit vectors, including two 128-bit stores which will be the throughput bottleneck along with the front-end.)
Even with -march=znver1 -O3 -mprefer-vector-width=256
, we don't get the *= 5
loop vectorized with GCC9, 10, or 11, or current trunk. As you say, we do with -march=znver2
. https://godbolt.org/z/dMTh7Wxcq
We do get vectorization with those options for uint32_t
(even leaving the vector width at 128-bit). Scalar would cost 4 operations per vector uop (not instruction), regardless of 128 or 256-bit vectorization on Zen1, so this doesn't tell us whether *=
is what makes the cost-model decide not to vectorize, or just the 2 vs. 4 elements per 128-bit internal uop.
With uint64_t
, changing to arr[i] += arr[i]<<2;
still doesn't vectorize, but arr[i] <<= 1;
does. (https://godbolt.org/z/6PMn93Y5G). Even arr[i] <<= 2;
and arr[i] += 123
in the same loop vectorize, to the same instructions that GCC thinks aren't worth it for vectorizing *= 5
, just different operands, constant instead of the original vector again. (Scalar could still use one LEA). So clearly the cost-model isn't looking as far as final x86 asm machine instructions, but I don't know why arr[i] += arr[i]
would be considered more expensive than arr[i] <<= 1;
which is exactly the same thing.
GCC8 does vectorize your loop, even with 128-bit vector width: https://godbolt.org/z/5o6qjc7f6
QUESTION
I have a few UI elements that I want stacked vertically, in the center of the panel, all aligned on the left edge of the center. I've tried to do this with a VBox, and it was working until I added an item that had text that was too long; it always truncates the text with ellipsis's and I can't get it to wrap the text down to the next line. I set the wrapText param to true on the Checkbox, but it doesn't seem to respect it. I've tried setting perfWidth and maxWidth on the checkbox and the vbox it is inside of but nothing seems to work. Can anyone tell me what I am doing wrong?
textwrap.fxml
...ANSWER
Answered 2022-Mar-21 at 23:27This is what I came up with, try it and see if it is what you want.
You may need to change some things to reach your final desired layout, but hopefully this addresses your immediate wrapping issue.
I think the BASELINE_CENTER
alignment on the outer VBox was confusing things, but I changed a couple of other things, so it may have been something else.
QUESTION
I am running an android app that is created using react native expo. It is running fine on windows machine android studio emulator Recently I switched to mac and this error is popping when I open the project in android studio.
...ANSWER
Answered 2022-Mar-22 at 15:54The problem is that you have different versions of that library. Make sure you use the same version on the mac too. Just remove the ^ for that library in package.json, then remove package-lock.json and node_modules and reinstall them.
You should have something like this: "react-native-reanimated": "2.3.1",
QUESTION
In my JavaFX project, I am trying to add an icon on Menu(mnAdmin) in the MenuBar using the CSS code below
...ANSWER
Answered 2021-Aug-23 at 04:31As suggested by kleopatra modified the code as stated below and it works well.
QUESTION
In my JavaFX project I'm using a lot of shapes(for example 1 000 000) to represent geographic data (such as plot outlines, streets, etc.). They are stored in a group and sometimes I have to clear them (for example when I'm loading a new file with new geographic data). The problem: clearing / removing them takes a lot of time. So my idea was to remove the shapes in a separate thread which obviously doesn't work because of the JavaFX singlethread.
Here is a simplified code of what I'm trying to do:
HelloApplication.java
...ANSWER
Answered 2022-Feb-21 at 20:14The long execution time comes from the fact that each child of a Parent
registers a listener with the disabled
and treeVisible
properties of that Parent
. The way JavaFX is currently implemented, these listeners are stored in an array (i.e. a list structure). Adding the listeners is relatively low cost because the new listener is simply inserted at the end of the array, with an occasional resize of the array. However, when you remove a child from its Parent
and the listeners are removed, the array needs to be linearly searched so that the correct listener is found and removed. This happens for each removed child individually.
So, when you clear the children list of the Group
you are triggering 1,000,000 linear searches for both properties, resulting in a total of 2,000,000 linear searches. And to make things worse, the listener to be removed is either--depending on the order the children are removed--always at the end of the array, in which case there's 2,000,000 worst case linear searches, or always at the start of the array, in which case there's 2,000,000 best case linear searches, but where each individual removal results in all remaining elements having to be shifted over by one.
There are at least two solutions/workarounds:
Don't display 1,000,000 nodes. If you can, try to only display nodes for the data that can actually be seen by the user. For example, the virtualized controls such as
ListView
andTableView
only display about 1-20 cells at any given time.Don't clear the children of the
Group
. Instead, just replace the oldGroup
with a newGroup
. If needed, you can prepare the newGroup
in a background thread.Doing it that way, it took 3.5 seconds on my computer to create another
Group
with 1,000,000 children and then replace the oldGroup
with the newGroup
. However, there was still a bit of a lag spike due to all the new nodes that needed to be rendered at once.If you don't need to populate the new
Group
then you don't even need a thread. In that case, the swap took about 0.27 seconds on my computer.
QUESTION
I am getting this issue in react native. The things were working fine until I decicded to rerun the project doing yarn install
Here is complete error
TypeError: undefined is not an object (evaluating '_expoModulesCore.NativeModulesProxy.ExpoSplashScreen') at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0 at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:294:29 in invoke at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at node_modules\regenerator-runtime\runtime.js:155:27 in invoke at node_modules\regenerator-runtime\runtime.js:165:18 in PromiseImpl.resolve.then$argument_0 at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
I have tried with update expo-cli, expo-splash-screen and with cache clear command expo r -c
Let me know if there is anyone who can help.
...ANSWER
Answered 2021-Dec-22 at 14:39You can show warnnigs of log? Because i have the same problem and resolved with.
Logs:
- expo-app-loading - expected version: 1.1.2 - actual version installed: 1.3.0
- react-native-screens - expected version: ~3.4.0 - actual version installed: 3.10.1
I used the versions 1.1.2 and 3.4.0 in my package: "react-native-screens": "^3.4.0" to "react-native-screens": "3.4.0" "expo-app-loading": "^1.1.2" to "expo-app-loading": "1.1.2"
Remove your node_modules, yarn.lock and package-lock.json
Yarn install or npm install
For me resolved.
QUESTION
I want to implement some kind of notification system in my application but I have trouble with the calculation of the actual position of my notification. All notifications should appear in a separate stage and each notification should be aligned among themselves and each notification is a simple VBox with two labels (title and message).
I created a little standalone application with the issue I have.
As soon as you press the button on the main stage, a VBox will be created and added to a second notification stage. As soon as a seconds notification needs to be added, this second notification should be below the first notification and so on. Therefore I need to find the height of the first notification in order to position the second notification underneath.
I know I could use a VBox instead, but in my application the notification should make a smooth animation and push the other notifications further down. I removed the whole animation and removing part of notifications so the example stays as small as possible.
The problem is that all notification boxes have the same height - but they don't (if you modify the text and make it longer / smaller).
...ANSWER
Answered 2022-Jan-29 at 09:43The short answer is use applyCss()
:
QUESTION
In the dataframe below:
...ANSWER
Answered 2021-Dec-25 at 08:46Just use the df.apply
method to average across each column based on series
and AIC_TRX
grouping.
QUESTION
I have 2 columns in pandas, with data that looks like this.
...ANSWER
Answered 2021-Dec-19 at 18:10We can get the expected result using split
like so :
QUESTION
I have a simple FX example with a simple component.
...ANSWER
Answered 2021-Dec-11 at 05:04Why you get artifacts
I think a different approach should be used rather than fixing the approach you have, but you could fix it if you want.
You are adding new rectangles and lines to your XPane in listeners. Every time the height or width changes, you add a new set of nodes, but the old set of nodes at the old height and widths remains. Eventually, if you resize enough, performance will drop or you will run out of memory or resources, making the program unusable.
A BorderPane paints its children (the center and the XPanes) in the order they were added without clipping, so these old lines will remain and the renderer will paint them over some panes as you resize. Similarly, some panes will paint over some lines because you are building up potentially lots of filled rectangles in the panes and they are partially overlapping lots of lines created.
To fix this, clear() the child node list in your populate() method before you add any new nodes.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fx
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page