发明名称 Finding the length of a set of character data having a termination character
摘要 The length of character data having a termination character is determined. The character data for which the length is to be determined is loaded, in parallel, within one or more vector registers. An instruction is used that loads data in a vector register to a specified boundary, and provides a way to determine the number of characters loaded, using, for instance, another instruction. Further, an instruction is used to find the index of the first termination character, e.g., the first zero or null character. This instruction searches the data in parallel for the termination character. By using these instructions, the length of the character data is determined using only one branch instruction.
申请公布号 US9323523(B2) 申请公布日期 2016.04.26
申请号 US201213421640 申请日期 2012.03.15
申请人 INTERNATIONAL BUSINESS MACHINES CORPORATION 发明人 Bradbury Jonathan D.;Gschwind Michael K.;Slegel Timothy J.
分类号 G06F12/00;G06F9/30 主分类号 G06F12/00
代理机构 Heslin Rothenberg Farley & Mesiti P.C. 代理人 Kinnaman, Esq. William A.;Hulihan, Esq. Matthew M.;Heslin Rothenberg Farley & Mesiti P.C.
主权项 1. A computer program product for determining a length of a set of data, the computer program product comprising: a non-transitory computer readable storage medium readable by a processing circuit and storing instructions for execution by the processing circuit for performing a method comprising: loading from memory to a register data that is within a specified block of memory, the data being at least a portion of the set of data for which the length is to be determined, the set of data for which the length is to be determined having a termination character, the termination character indicating an end of the set of data for which the length is to be determined and being a known fixed value pre-selected as the value to specify termination of sets of data, wherein the loading comprises loading from a starting address in memory to an ending address in memory, wherein the ending address is computed using a boundary size of the specified block of memory and a boundary mask, the boundary mask determined based on the boundary size and used to determine closeness to a specified boundary, and wherein a variable number of bytes of data are loaded from memory absent crossing the specified boundary of the block of memory from which the data is being loaded in the register, the variable number based on the starting address and the ending address;obtaining a count of an amount of data loaded in the register;determining, by a processor, a termination value for the data loaded in the register, the termination value to be used in determining the length of the set of data, the determining comprising checking the data loaded in the register to determine whether the data loaded in the register includes the termination character at a location within the register, and based on the data loaded in the register including the termination character, setting the termination value to a value indicating the location within the register of the termination character, and based on the data loaded in the register not including the termination character, setting the termination value to a pre-specified value to be used in determining the length of the set of data;checking whether there is additional data to be counted based on at least one of the count and the termination value;based on the checking indicating additional data is to be counted, incrementing the count based on the additional data, the incrementing including counting the additional data up to but excluding the termination character, the incremented count providing the length of the set of data; andbased on the checking indicating additional data is not to be counted, using the termination value as the length of the set of data.
地址 Armonk NY US