Skip to content

Commit

Permalink
[******][GPU] Make unsafe_pointer GPU agnostic
Browse files Browse the repository at this point in the history
MODULAR_ORIG_COMMIT_REV_ID: 85797bf247f55c80748fc56d468a9d8c2e0e2767
  • Loading branch information
abduld authored and modularbot committed Nov 14, 2024
1 parent 5db93d2 commit 076c9b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stdlib/src/memory/unsafe_pointer.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from memory import UnsafePointer
```
"""

from sys import alignof, sizeof, is_nvidia_gpu
from sys import alignof, sizeof, is_nvidia_gpu, is_gpu
from sys.intrinsics import (
_mlirtype_is_eq,
_type_is_eq,
Expand All @@ -40,7 +40,7 @@ from memory.memory import _free, _malloc

@always_inline
fn _default_alignment[type: AnyType]() -> Int:
return alignof[type]() if is_nvidia_gpu() else 1
return alignof[type]() if is_gpu() else 1


@always_inline
Expand Down Expand Up @@ -842,7 +842,7 @@ struct UnsafePointer[
type: DType, //,
*,
width: Int = 1,
alignment: Int = alignof[SIMD[type, width]]() if is_nvidia_gpu() else 1,
alignment: Int = _default_alignment[type, width](),

This comment has been minimized.

Copy link
@sibarras

sibarras Nov 14, 2024

Is it ok to provide two parameters to this function? I would expect:

alignment: Int = _default_alignment[SIMD[type, width]](),

But not sure if there something I don't know about the lang

](
self: UnsafePointer[Scalar[type], *_, **_],
offset: SIMD[_, width],
Expand Down
1 change: 1 addition & 0 deletions stdlib/src/sys/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ from .info import (
warpsize,
sizeof,
is_nvidia_gpu,
is_gpu,
)
from .intrinsics import (
PrefetchCache,
Expand Down

0 comments on commit 076c9b9

Please sign in to comment.