# US 2020/0265097 A1 · Vector string search instruction

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2020/0265097 A1
- Document ID: US20200265097A1
- Status: Published application
- Kind: A1
- Application number: 16/276,712
- Filed: 2019-02-15
- Published: 2020-08-20
- Earliest claimed: 2019-02-15
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Cedric LICHTENAU; Jonathan D. BRADBURY; Eric M. SCHWARZ; Razvan Peter FIGULI; Stefan PAYER
- Web page: https://patentgrep.com/patent/US20200265097A1

## CPC

- G06F 16/90344: {by using string matching techniques}
- G06F 17/16: Matrix or vector computation {, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization (matrix transposition G06F7/78)}
- G06F 40/205: Parsing
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An instruction is provided for performing a vector string search. The instruction to be processed is obtained, with the instruction being defined to be a string search instruction to locate occurrence of a substring within a string. The instruction is processed, with the processing including searching the string specified in one operand of the instruction using the substring specified in another operand of the instruction. Based on the searching locating a first full match of the substring within the string, a full match condition indication is returned with position of the first full match in the string, and based on the searching locating only a partial match of the substring at a termination of the string, a partial match condition indication is returned, with the position of the partial match in the string.

## Claims

### Claim 1

A computer program product for facilitating processing within a computing environment, the computer program product comprising:
a computer-readable storage medium readable by a processing circuit and storing instructions for performing a method comprising:
obtaining an instruction to be processed, the instruction defined to be a string search instruction to locate occurrence of a substring within a string;
processing the instruction, the processing comprising:
searching the string specified in one operand of the instruction using the substring specified in another operand of the instruction;
based on the searching locating a first full match of the substring within the string, returning a full match condition indication with position of the first full match in the string; and
based on the searching locating only a partial match of the substring at a termination of the string, returning a partial match condition indication with position of the partial match in the string.

### Claim 2 (depends on 1)

The computer program product of claim 1, wherein the processing further comprises, based on the searching locating no-match of the substring within the string, returning a no-match condition indication with a search completion position of n, n being a length of the string in bytes.

### Claim 3 (depends on 1)

The computer program product of claim 1, wherein the processing further comprises determining a mode for the searching, the searching including a non-zero-terminated search mode and a zero-terminated search mode, and the determining being based on whether a zero-search flag in a field of the instruction is set to indicate that the string or sub string can contain a zero termination that truncates the string or sub string, respectively, for the searching.

### Claim 4 (depends on 3)

The computer program product of claim 3, wherein the processing further comprises, based on the mode for the searching being the zero-terminated search mode, determining that the string includes the zero termination, and based thereon, setting a zero-termination found indicator.

### Claim 5 (depends on 4)

The computer program product of claim 4, wherein the processing further comprises, based on the searching reaching the zero termination within the string without a match, terminating the searching and returning, with reference to the zero-termination found indicator, a no-match with zero termination condition indication, with a search completion position of n, n being a length of the string in bytes.

### Claim 6 (depends on 4)

The computer program product of claim 4, wherein the determining further comprises determining that a length of the string before the zero termination within the string is smaller than the substring length, and based thereon, determining whether a portion of the substring matches the string before the zero termination.

### Claim 7 (depends on 1)

The computer program product of claim 1, further comprising proceeding with the searching based on a length of the substring being a multiple of a size of elements within the string, the size being determined from a field of the instruction.

### Claim 8 (depends on 7)

The computer program product of claim 7, wherein the searching is based, in part, on the size of the elements within the string, the searching including element-based stepping through the string, wherein the size is selected from the group consisting of 1 byte, 2 bytes, or 4 bytes.

### Claim 9 (depends on 1)

The computer program product of claim 1, wherein the string search instruction is an architected hardware machine instruction of an instruction set architecture.

### Claim 10 (depends on 9)

The computer program product of claim 9, wherein the architected hardware machine instruction is a vector string search instruction.

### Claim 11

A computer system for facilitating processing within a computing environment, the computer system comprising:
a memory; and
a processor coupled to the memory, wherein the computer system is configured to perform a method comprising:
obtaining an instruction to be processed, the instruction defined to be a string search instruction to locate occurrence of a substring within a string;
processing the instruction, the processing comprising:
searching the string specified in one operand of the instruction using the substring specified in another operand of the instruction;
based on the searching locating a first full match of the substring within the string, returning a full match condition indication with position of the first full match in the string; and
based on the searching locating only a partial match of the substring at a termination of the string, returning a partial match condition indication with position of the partial match in the string.

### Claim 12 (depends on 11)

The computer system of claim 11, wherein the processing further comprises, based on the searching locating no-match of the substring within the string, returning a no-match condition indication with a search completion position of n, n being a length of the string in bytes.

### Claim 13 (depends on 11)

The computer system of claim 11, wherein the processing further comprises determining a mode for the searching, the searching including a non-zero-terminated search mode and a zero-terminated search mode, and the determining being based on whether a zero-search flag in a field of the instruction is set to indicate that the string or substring can contain a zero termination that truncates the string or substring, respectively, for the searching.

### Claim 14 (depends on 13)

The computer system of claim 13, wherein the processing further comprises, based on the mode for the searching being the zero-terminated search mode, determining that the string includes the zero termination, and based thereon, setting a zero-termination found indicator.

### Claim 15 (depends on 14)

The computer system of claim 14, wherein the processing further comprises, based on the searching reaching the zero termination within the string without a match, terminating the searching and returning, with reference to the zero-termination found indicator, a no-match with zero termination condition indication, with a search completion position of n, n being a length of the string in bytes.

### Claim 16 (depends on 14)

The computer system of claim 14, wherein the determining further comprises determining that a length of the string before the zero termination within the string is smaller than the substring length, and based thereon, determining whether a portion of the substring matches the string before the zero termination.

### Claim 17 (depends on 11)

The computer system of claim 11, further comprising proceeding with the searching based on a length of the substring being a multiple of a byte size of elements within the string, the byte size being determined from a field of the instruction, and wherein the searching is based, in part, on the byte size of the elements within the string, the searching including element-based stepping through the string, wherein the byte size is selected from the group consisting of 1 byte, 2 bytes, or 4 bytes.

### Claim 18

A computer-implemented method of facilitating processing within a computing environment, the computer-implemented method comprising:
obtaining an instruction to be processed, the instruction defined to be a string search instruction to locate occurrence of a substring within a string;
processing the instruction, the processing comprising:
searching the string specified in one operand of the instruction using the substring specified in another operand of the instruction;
based on the searching locating a first full match of the substring within the string, returning a full match condition indication with position of the first full match in the string; and
based on the searching locating only a partial match of the substring at a termination of the string, returning a partial match condition indication with position of the partial match in the string.

### Claim 19 (depends on 18)

The computer-implemented method of claim 18, wherein the processing further comprises, based on the searching locating no-match of the substring within the string, returning a no-match condition indication with a search completion position of n, n being a length of the string in bytes.

### Claim 20 (depends on 18)

The computer-implemented method of claim 18, wherein the processing further comprises determining a mode for the searching, the searching including a non-zero-terminated search mode and a zero-terminated search mode, and the determining being based on whether a zero-search flag in a field of the instruction is set to indicate that the string or substring can contain a zero termination that truncates the string or substring, respectively, for the searching.
