Skip to content
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

[mono] Intrinsify multiple LoadVector API's #98077

Merged
merged 12 commits into from
Feb 12, 2024

Conversation

fanyang-mono
Copy link
Member

@fanyang-mono fanyang-mono commented Feb 7, 2024

Contributes to #93081

This PR intrinsify the following API's:

  • AdvSimd.LoadVector64x*
  • AdvSimd.Arm64.LoadVector128x*
  • AdvSimd.LoadVector64x*AndUnzip
  • AdvSimd.Arm64.LoadVector128x*AndUnzip
  • AdvSimd.LoadAndReplicateToVector64x*
  • AdvSimd.Arm64.LoadAndReplicateToVector128x*

@ghost
Copy link

ghost commented Feb 7, 2024

Tagging subscribers to this area: @SamMonoRT, @fanyang-mono
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: fanyang-mono
Assignees: -
Labels:

area-Codegen-Intrinsics-mono

Milestone: -

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@fanyang-mono
Copy link
Member Author

Mostly working. There is some issue with emitting insertvalue, which I am still working on.

@kunalspathak
Copy link
Member

cc: @a74nh @SwapnilGaikwad

@fanyang-mono
Copy link
Member Author

Mostly working. There is some issue with emitting insertvalue, which I am still working on.

This has been resolved. The PR is ready to review.

@fanyang-mono fanyang-mono marked this pull request as ready for review February 8, 2024 17:44
@fanyang-mono fanyang-mono changed the title [mono] Intrinsify LoadVector64x* and LoadVector128x* [mono] Intrinsify LoadVector64x*, LoadVector128x*, LoadVector64x*AndUnzip and LoadVector128x*AndUnzip Feb 8, 2024
@kunalspathak
Copy link
Member

@fanyang-mono - can you trigger a pipeline that run these tests under mono? I think it was extra-platform or something?

@@ -1642,6 +1642,8 @@ MINI_OP(OP_ARM64_LDNP_SCALAR, "arm64_ldnp_scalar", VREG, IREG, NONE)
MINI_OP(OP_ARM64_LDP, "arm64_ldp", VREG, IREG, NONE)
MINI_OP(OP_ARM64_LDP_SCALAR, "arm64_ldp_scalar", VREG, IREG, NONE)

MINI_OP(OP_ARM64_LDM, "arm64_ldm", VREG, IREG, NONE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these custom names specific for mono? Can we write a comment for them because there will be more coming for store? Also, should arm64_ldm reused for LoadVector* and LoadAndUnzip?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the custom names used in this file are specific for Mono IR. For LLVM codegen, they follows similar logic, so I use the same string for both LoadVector* and LoadAndUnzip

@@ -13546,6 +13563,10 @@ add_intrinsic (EmitContext *ctx, int id)
*/
LLVMTypeRef associated_type = intrin_types [vw][0];
intrins = add_intrins2 (module, id, distinguishing_type, associated_type, &intrins_type);
} else if (kind == INTRIN_kind_add_pointer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change about and why we have to track this separately? Mono supported APIs that takes pointers, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to calling LLVM intrinsics. Yes, Mono supports pointer type.

@ghost ghost added needs-author-action An issue or pull request that requires more info or actions from the author. and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Feb 8, 2024
@steveisok
Copy link
Member

@fanyang-mono build failures are related. This is one from tvos-arm64

mini-llvm.c:11641:45: error: incompatible pointer types passing 'MonoLLVMModule *' to parameter of type 'EmitContext *' [-Werror,-Wincompatible-pointer-types]
                                  addresses [ins->dreg] = create_address (ctx->module, build_named_alloca (ctx, m_class_get_byval_arg (ins->klass), oname), ret_t);
                                                                          ^~~~~~~~~~~
  /Users/runner/work/1/s/src/mono/mono/mini/mini-llvm.c:616:30: note: passing argument to parameter 'ctx' here
  create_address (EmitContext *ctx, LLVMValueRef value, LLVMTypeRef type)

@fanyang-mono
Copy link
Member Author

The latest commit should be able to resolve this build failure.

@fanyang-mono
Copy link
Member Author

/azp run runtime-llvm

@kunalspathak
Copy link
Member

Why not also implement LoadVectorAndInsertScalar in this PR and get done with all the load APIs?

@fanyang-mono
Copy link
Member Author

CI failures are known.

@fanyang-mono
Copy link
Member Author

Why not also implement LoadVectorAndInsertScalar in this PR and get done with all the load APIs?

The LLVM intrinsic that needs to be emitted is a little different. I need more time to make sure everything around it works properly. This PR is ready to be merged. Thus, I would prefer to get this one merged soon.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just make sure the tests you enabled ran and passed on mono.

@fanyang-mono fanyang-mono merged commit 8e2dcfa into dotnet:main Feb 12, 2024
186 of 189 checks passed
@fanyang-mono
Copy link
Member Author

CI lane (Mono full AOT with LLVM running runtime tests on arm64) which could validate this change is currently off. Here is the result from local run on my machine:

Result from local run:
Supported ISAs:
  AdvSimd:   True
  Aes:       True
  ArmBase:   True
  Crc32:     True
  Dp:        False
  Rdm:       False
  Sha1:      True
  Sha256:    True
  Sve:       False
 
.......
 
Expected: 100
Actual: 100
END EXECUTION - PASSED

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants