File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ struct FastaRecord:
6666 # Find the first newline in the buffer
6767 var header_line_end = memchr(buffer, ord (" \n " ))
6868 if header_line_end == - 1 :
69- print (StringSlice(unsafe_from_utf8 = buffer))
7069 raise " No newline found for FASTA record header"
7170
7271 var name = String()
Original file line number Diff line number Diff line change 11from collections import Optional
22from gpu.host import DeviceBuffer
33from memory import Span, UnsafePointer
4+ from sys.info import sizeof, simdwidthof
5+ from sys.param_env import env_get_string
46
57from ishlib.matcher.alignment.scoring_matrix import MatrixKind
68from ishlib.searcher_settings import SemiGlobalEndsFreeness
79
810
11+ fn simd_width_selector [dtype : DType]() -> Int:
12+ """ Select a SIMD width for a given type.
13+
14+ This will override the `simdwidthof` if the env var ISH_SIMD_TARGET=baseline
15+ """
16+ constrained[sizeof[Scalar[dtype]]() <= 16 , " dytpe size too large." ]()
17+ alias target = env_get_string[" ISH_SIMD_TARGET" , " none" ]().lower()
18+ alias SSE_U8_SIZE = 16
19+
20+ @parameter
21+ if target == " baseline" :
22+ return SSE_U8_SIZE // sizeof[Scalar[dtype]]()
23+ else :
24+ return simdwidthof[dtype]()
25+
26+
927@value
1028@register_passable (" trivial" )
1129struct MatchResult :
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ from sys.info import (
55)
66
77from ishlib.vendor.log import Logger
8- from ishlib.matcher import Matcher, MatchResult
8+ from ishlib.matcher import Matcher, MatchResult, simd_width_selector
99from ishlib.matcher.alignment import create_reversed
1010from ishlib.matcher.alignment.scoring_matrix import ScoringMatrix, MatrixKind
1111from ishlib.matcher.alignment.local_aln.striped import (
@@ -17,8 +17,8 @@ from ishlib.matcher.alignment.local_aln.striped import (
1717
1818@value
1919struct StripedLocalMatcher[mut: Bool, // , origin: Origin[mut]](Matcher):
20- alias SIMD_U8_WIDTH = simdwidthof[UInt8 ]()
21- alias SIMD_U16_WIDTH = simdwidthof[UInt16 ]()
20+ alias SIMD_U8_WIDTH = simd_width_selector[DType.uint8 ]()
21+ alias SIMD_U16_WIDTH = simd_width_selector[DType.uint16 ]()
2222
2323 var pattern : List[UInt8]
2424 var rev_pattern : List[UInt8]
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ from gpu.host import DeviceContext
33from sys.info import simdwidthof
44
55from ishlib.gpu.kernels.semi_global import gpu_align_coarse
6- from ishlib.matcher import Matcher, MatchResult
6+ from ishlib.matcher import Matcher, MatchResult, simd_width_selector
77from ishlib.matcher.alignment import create_reversed
88from ishlib.matcher.alignment.scoring_matrix import ScoringMatrix, MatrixKind
99from ishlib.matcher.alignment.semi_global_aln.striped import (
@@ -18,12 +18,9 @@ from ishlib.vendor.log import Logger
1818
1919@value
2020struct StripedSemiGlobalMatcher (GpuMatcher ):
21- alias SIMD_U8_WIDTH = simdwidthof[
22- UInt8
23- ]() # // 4 # TODO : needs tuning on wider machines
24- alias SIMD_U16_WIDTH = simdwidthof[
25- UInt16
26- ]() # // 4 # TODO : needs tuning on wider machines
21+ alias SIMD_U8_WIDTH = simd_width_selector[DType.uint8]()
22+ alias SIMD_U16_WIDTH = simd_width_selector[DType.uint16]()
23+
2724 var pattern : List[UInt8]
2825 var rev_pattern : List[UInt8]
2926 var max_score : Int
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ version = "1.1.0"
1212
1313[tasks ]
1414build = " pixi run mojo build -D ISH_LOG_LEVEL=info --march native -o ish main.mojo"
15+ build_generic = " pixi run mojo build -D ISH_SIMD_TARGET=baseline -D ISH_LOG_LEVEL=info -o ish main.mojo"
1516debug = " pixi run mojo build -D ISH_LOG_LEVEL=debug --debug-level line-tables --march native -o ish main.mojo"
1617pkglib = " pixi run mojo package ./ishlib"
1718testlib = " pixi run mojo test tests -I . --co && pixi run mojo test tests -I ."
You can’t perform that action at this time.
0 commit comments