我目前正在自学 SIMD 并且正在编写一个相当简单的字符串处理子程序。然而,我仅限于 SSE2,这使我无法利用 ptest 找到空终端。
我目前试图找到空终端的方式使我的 SIMD 循环有 >16 条指令,这违背了使用 SIMD 的目的 - 或者至少使它不那么值得。
//Check for null byte
pxor xmm4, xmm4
pcmpeqb xmm4, [rdi] //Generate bitmask
movq rax, xmm4
test rax, 0xffffffffffffffff //Test low qword
jnz .Lepilogue
movhlps xmm4, xmm4 //Move high into low qword
movq rax, xmm4
test rax, 0xffffffffffffffff //Test high qword
jz .LsimdLoop //No terminal was found, keep looping
Run Code Online (Sandbox Code Playgroud)
我想知道在没有 ptest 的情况下是否有任何更快的方法可以做到这一点,或者这是否是最好的方法,我将不得不再优化循环的其余部分。
注意:我确保输入使用 SIMD 的循环的字符串地址是 16B 对齐的,以允许对齐的指令。
我正在尝试设置一个回收器视图,并使用 ConstraintLayout 显示元素。我使用Google 示例中的布局作为指导。
然而,尽管android:layout_width="match_parent"
一路向下指定,最终显示在屏幕上的结果更类似于wrap_content
.
android:layout_width=0
,同时使用ConstraintLayout并将start、end 和 top 锚定到父级如果缺少任何其他感兴趣的内容,请告诉我。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/recipe_entry_height" >
<TextView
android:id="@+id/recipe_title"
style="@style/Widget.RecipeTracker.ListItemTextView"
android:layout_marginHorizontal="@dimen/margin_between_elements"
android:background="@color/design_default_color_on_secondary"
android:layout_width="match_parent"
android:fontFamily="sans-serif"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:maxLines="1"
android:ellipsize="end"
tools:text="amazing stuff"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.RecipeTracker.ListItemTextView" parent="Widget.MaterialComponents.TextView">
<item name="android:gravity">center_vertical</item>
<item name="android:layout_height">48dp</item>
<item …
Run Code Online (Sandbox Code Playgroud) android android-layout kotlin android-recyclerview android-constraintlayout