Browse Source

Make `simd_util` index procs `contextless` where applicable

Feoramund 1 year ago
parent
commit
c8a62ee4ec

+ 2 - 2
core/bytes/bytes.odin

@@ -297,7 +297,7 @@ split_after_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
 
 
 
 
 index_byte :: proc(s: []byte, c: byte) -> int {
 index_byte :: proc(s: []byte, c: byte) -> int {
-	_index_byte :: #force_inline proc(s: []byte, c: byte) -> int {
+	_index_byte :: #force_inline proc "contextless" (s: []byte, c: byte) -> int {
 		for i := 0; i < len(s); i += 1 {
 		for i := 0; i < len(s); i += 1 {
 			if s[i] == c {
 			if s[i] == c {
 				return i
 				return i
@@ -318,7 +318,7 @@ index_byte :: proc(s: []byte, c: byte) -> int {
 
 
 // Returns -1 if c is not present
 // Returns -1 if c is not present
 last_index_byte :: proc(s: []byte, c: byte) -> int {
 last_index_byte :: proc(s: []byte, c: byte) -> int {
-	_last_index_byte :: #force_inline proc(s: []byte, c: byte) -> int {
+	_last_index_byte :: #force_inline proc "contextless" (s: []byte, c: byte) -> int {
 		for i := len(s)-1; i >= 0; i -= 1 {
 		for i := len(s)-1; i >= 0; i -= 1 {
 			if s[i] == c {
 			if s[i] == c {
 				return i
 				return i

+ 2 - 2
core/simd/util/util.odin

@@ -34,7 +34,7 @@ Inputs:
 Returns:
 Returns:
 - index: The index of the byte `c`, or -1 if it was not found.
 - index: The index of the byte `c`, or -1 if it was not found.
 */
 */
-index_byte :: proc(data: []u8, c: byte) -> (index: int) #no_bounds_check {
+index_byte :: proc "contextless" (data: []u8, c: byte) -> (index: int) #no_bounds_check {
 	length := len(data)
 	length := len(data)
 	i := 0
 	i := 0
 
 
@@ -101,7 +101,7 @@ Inputs:
 Returns:
 Returns:
 - index: The index of the byte `c`, or -1 if it was not found.
 - index: The index of the byte `c`, or -1 if it was not found.
 */
 */
-last_index_byte :: proc(data: []u8, c: byte) -> int #no_bounds_check {
+last_index_byte :: proc "contextless" (data: []u8, c: byte) -> int #no_bounds_check {
 	length := len(data)
 	length := len(data)
 	i := length - 1
 	i := length - 1
 
 

+ 2 - 2
core/strings/strings.odin

@@ -1426,7 +1426,7 @@ Output:
 
 
 */
 */
 index_byte :: proc(s: string, c: byte) -> (res: int) {
 index_byte :: proc(s: string, c: byte) -> (res: int) {
-	_index_byte :: #force_inline proc(s: string, c: byte) -> int {
+	_index_byte :: #force_inline proc "contextless" (s: string, c: byte) -> int {
 		for i := 0; i < len(s); i += 1 {
 		for i := 0; i < len(s); i += 1 {
 			if s[i] == c {
 			if s[i] == c {
 				return i
 				return i
@@ -1477,7 +1477,7 @@ Output:
 
 
 */
 */
 last_index_byte :: proc(s: string, c: byte) -> (res: int) {
 last_index_byte :: proc(s: string, c: byte) -> (res: int) {
-	_last_index_byte :: #force_inline proc(s: string, c: byte) -> int {
+	_last_index_byte :: #force_inline proc "contextless" (s: string, c: byte) -> int {
 		for i := len(s)-1; i >= 0; i -= 1 {
 		for i := len(s)-1; i >= 0; i -= 1 {
 			if s[i] == c {
 			if s[i] == c {
 				return i
 				return i

+ 3 - 3
tests/benchmark/simd/util/benchmark_simd_util.odin

@@ -9,7 +9,7 @@ import "core:time"
 
 
 // These are the normal, unoptimized algorithms.
 // These are the normal, unoptimized algorithms.
 
 
-plain_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
+plain_index_byte :: proc "contextless" (s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	for i := 0; i < len(s); i += 1 {
 	for i := 0; i < len(s); i += 1 {
 		if s[i] == c {
 		if s[i] == c {
 			return i
 			return i
@@ -18,7 +18,7 @@ plain_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	return -1
 	return -1
 }
 }
 
 
-plain_last_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
+plain_last_index_byte :: proc "contextless" (s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	for i := len(s)-1; i >= 0; i -= 1 {
 	for i := len(s)-1; i >= 0; i -= 1 {
 		if s[i] == c {
 		if s[i] == c {
 			return i
 			return i
@@ -37,7 +37,7 @@ sizes := [?]int {
 	1024 * 1024 * 1024,
 	1024 * 1024 * 1024,
 }
 }
 
 
-run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, warmup: int, runs: int) -> (timing: time.Duration) {
+run_trial_size :: proc(p: proc "contextless" ([]u8, byte) -> int, size: int, idx: int, warmup: int, runs: int) -> (timing: time.Duration) {
 	data := make([]u8, size)
 	data := make([]u8, size)
 	defer delete(data)
 	defer delete(data)