Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

# Next

# v1.3.0 (07-21-2025)

- Switch to using signed ints instead of unsigned for semi-global
- Fix alignment score check used to decided whether or not to do the reverse alignment for semi-global and local alignment
- Allow specifying simd width via a flag at comple time
- Fix / updates the bench_aligner for current stable Mojo

# v1.2.1 (06-25-2025)

- Fixed bug in logging module related to update from Mojo 24.3 to 24.4 replacing `write_args`.
Expand Down
30 changes: 15 additions & 15 deletions benchmarking/ish_bench_aligner.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ struct ByteFastaRecord:
seq_bytes = scoring_matrix.convert_ascii_to_encoding(seq_bytes)
var rev = List[UInt8](capacity=len(seq_bytes))
for s in reversed(seq_bytes):
rev.append(s[])
rev.append(s)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All updates for latest mojo version, skippable review wise.

self.name = name^
self.seq = seq_bytes^
self.rev = rev^
Expand Down Expand Up @@ -329,26 +329,26 @@ struct BenchmarkResults(ToDelimited):
var gcups = 0.0

for result in results:
total_query_seqs += result[].total_query_seqs
total_target_seqs += result[].total_target_seqs
runtime_secs += result[].runtime_secs
cells_updated += result[].cells_updated
gcups += result[].gcups
total_query_seqs += result.total_query_seqs
total_target_seqs += result.total_target_seqs
runtime_secs += result.runtime_secs
cells_updated += result.cells_updated
gcups += result.gcups

if query_len != result[].query_len:
if query_len != result.query_len:
# TODO: may want to change this if we want to process multiple queries in one go.
raise "Mismatching query len"
if matrix != result[].matrix:
if matrix != result.matrix:
raise "Mismatching matrix"
if gap_open != result[].gap_open:
if gap_open != result.gap_open:
raise "Mismatching gap open"
if gap_extend != result[].gap_extend:
if gap_extend != result.gap_extend:
raise "Mismatching gap extend"
if u8_width != result[].u8_width:
if u8_width != result.u8_width:
raise "Mismatching u8 width"
if u16_width != result[].u16_width:
if u16_width != result.u16_width:
raise "Mismatching u16 width"
if score_size != result[].score_size:
if score_size != result.score_size:
raise "Mismatching score size"

return Self(
Expand Down Expand Up @@ -518,7 +518,7 @@ fn bench_striped_local(
)
for q in queries:
profiles.append(
Profiles[SIMD_U8_WIDTH, SIMD_U16_WIDTH](q[], matrix, score_size)
Profiles[SIMD_U8_WIDTH, SIMD_U16_WIDTH](q, matrix, score_size)
)
var prep_end = perf_counter()
print("Setup Time:", prep_end - prep_start, file=stderr)
Expand Down Expand Up @@ -644,7 +644,7 @@ fn bench_striped_semi_global(
for q in queries:
profiles.append(
SemiGlobalProfiles[SIMD_U8_WIDTH, SIMD_U16_WIDTH](
q[], matrix, score_size
q, matrix, score_size
)
)
var prep_end = perf_counter()
Expand Down
4 changes: 3 additions & 1 deletion ishlib/gpu/searcher_device.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ struct SearcherDevice[func_type: AnyTrivialRegType, //, func: func_type]:
max_devices: Int,
) raises -> List[Self]:
var ret = List[Self]()
for i in range(0, min(DeviceContext.number_of_devices(), max_devices)):
for i in range(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hardcoded to max of 1 for now. Warning will happen in SearcherSettings if you set it above 1. This is because there isn't a good way to filter out non-compatible GPUs.

0, min(DeviceContext.number_of_devices(), min(1, max_devices))
):
var device = DeviceContext(i)
# Triple check it's a gpu
if device.api() == "cuda" or device.api() == "hip":
Expand Down
8 changes: 7 additions & 1 deletion ishlib/matcher/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ fn simd_width_selector[dtype: DType]() -> Int:
constrained[sizeof[Scalar[dtype]]() <= 16, "dytpe size too large."]()
alias target = env_get_string["ISH_SIMD_TARGET", "none"]().lower()
alias SSE_U8_SIZE = 16
alias AVX_256_U8_SIZE = 32
alias AVX_512_U8_SIZE = 64

@parameter
if target == "baseline":
if target == "baseline" or target == "sse":
return SSE_U8_SIZE // sizeof[Scalar[dtype]]()
elif target == "avx256":
return AVX_256_U8_SIZE // sizeof[Scalar[dtype]]()
elif target == "avx512":
return AVX_512_U8_SIZE // sizeof[Scalar[dtype]]()
else:
return simdwidthof[dtype]()

Expand Down
3 changes: 3 additions & 0 deletions ishlib/matcher/alignment/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct AlignedMemory[dtype: DType, width: Int, alignment: Int](
if zero_mem:
memset_zero(self.ptr, self.length)

@always_inline
fn __getitem__[
I: Indexer
](ref self, offset: I) -> ref [self] SIMD[dtype, width]:
Expand All @@ -78,9 +79,11 @@ struct AlignedMemory[dtype: DType, width: Int, alignment: Int](
fn __del__(owned self):
self.ptr.free()

@always_inline
fn __len__(read self) -> Int:
return self.length

@always_inline
fn as_span(
ref self,
) -> Span[SIMD[self.dtype, self.width], __origin_of(self)]:
Expand Down
8 changes: 5 additions & 3 deletions ishlib/matcher/alignment/local_aln/striped.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn ssw_align[
gap_extension_penalty: UInt8 = 1,
return_only_alignment_end: Bool = False,
mask_length: Int32 = 15, # for second best score
score_cutoff: Int32 = 0,
score_cutoff: Float32 = 0.0,
) -> Optional[Alignment]:
# Find the alignment scores and ending positions
var bests: AlignmentResult
Expand Down Expand Up @@ -212,7 +212,7 @@ fn ssw_align[
Logger.warn("Failed to provide a valid query profile")
return None

if bests.best.score <= score_cutoff:
if Float32(bests.best.score) <= score_cutoff:
Logger.debug("Worse than cutoff")
return None

Expand Down Expand Up @@ -294,7 +294,9 @@ fn sw[
p_vecs.init_columns(len(reference))
var max_score = UInt8(0).cast[dt]()
var end_query: Int32 = query_len - 1
var end_reference: Int32 = -1 # 0 based best alignment ending point; initialized as isn't aligned -1
var end_reference: Int32 = (
-1
) # 0 based best alignment ending point; initialized as isn't aligned -1
var segment_length = p_vecs.segment_length

# Note:
Expand Down
Loading