Debian Codegraph @

examples/common/library_get_started.cpp

raw
1 /*************************************************************************
2 * Copyright (C) 2025 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *************************************************************************/
16 /*!
17 *
18 * \file
19 *
20 * \brief Get Started example
21 *
22 * This example demonstrates usage of cryptoGetLibVersion and ippcpGetCpuFeatures functions work
23 *
24 */
25
26 #include <stdio.h>
27
28 #include "ippcp.h"
29 #include "examples_common.h"
30
31 int main(int argc, char* argv[])
32 {
33 const CryptoLibraryVersion* lib;
34 IppStatus status;
35 Ipp64u mask, emask;
36
37 /*! Get Intel(R) Cryptography Primitives Library version info */
38 lib = cryptoGetLibVersion();
39 printf("%s\n", lib->strVersion);
40
41 /*! Get CPU features and features enabled with selected library level */
42 status = ippcpGetCpuFeatures(&mask);
43 if (ippStsNoErr == status) {
44 emask = ippcpGetEnabledCpuFeatures();
45 printf("Features supported by CPU\tby Intel(R) Cryptography Primitives Library\n");
46 printf("-----------------------------------------\n");
47 printf(" ippCPUID_MMX = ");
48 printf("%c\t%c\t", (mask & ippCPUID_MMX) ? 'Y' : 'N', (emask & ippCPUID_MMX) ? 'Y' : 'N');
49 printf("Intel(R) Architecture MMX technology supported\n");
50 printf(" ippCPUID_SSE = ");
51 printf("%c\t%c\t", (mask & ippCPUID_SSE) ? 'Y' : 'N', (emask & ippCPUID_SSE) ? 'Y' : 'N');
52 printf("Intel(R) Streaming SIMD Extensions (Intel(R) SSE)\n");
53 printf(" ippCPUID_SSE2 = ");
54 printf("%c\t%c\t", (mask & ippCPUID_SSE2) ? 'Y' : 'N', (emask & ippCPUID_SSE2) ? 'Y' : 'N');
55 printf("Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2)\n");
56 printf(" ippCPUID_SSE3 = ");
57 printf("%c\t%c\t", (mask & ippCPUID_SSE3) ? 'Y' : 'N', (emask & ippCPUID_SSE3) ? 'Y' : 'N');
58 printf("Intel(R) Streaming SIMD Extensions 3 (Intel(R) SSE3)\n");
59 printf(" ippCPUID_SSSE3 = ");
60 printf("%c\t%c\t",
61 (mask & ippCPUID_SSSE3) ? 'Y' : 'N',
62 (emask & ippCPUID_SSSE3) ? 'Y' : 'N');
63 printf("Supplemental Streaming SIMD Extensions 3 (SSSE3)\n");
64 printf(" ippCPUID_MOVBE = ");
65 printf("%c\t%c\t",
66 (mask & ippCPUID_MOVBE) ? 'Y' : 'N',
67 (emask & ippCPUID_MOVBE) ? 'Y' : 'N');
68 printf("The processor supports MOVBE instruction\n");
69 printf(" ippCPUID_SSE41 = ");
70 printf("%c\t%c\t",
71 (mask & ippCPUID_SSE41) ? 'Y' : 'N',
72 (emask & ippCPUID_SSE41) ? 'Y' : 'N');
73 printf("Intel(R) Streaming SIMD Extensions 4.1 (Intel(R) SSE4.1)\n");
74 printf(" ippCPUID_SSE42 = ");
75 printf("%c\t%c\t",
76 (mask & ippCPUID_SSE42) ? 'Y' : 'N',
77 (emask & ippCPUID_SSE42) ? 'Y' : 'N');
78 printf("Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2)\n");
79 printf(" ippCPUID_AVX = ");
80 printf("%c\t%c\t", (mask & ippCPUID_AVX) ? 'Y' : 'N', (emask & ippCPUID_AVX) ? 'Y' : 'N');
81 printf("Intel(R) Advanced Vector Extensions (Intel(R) AVX) instruction set\n");
82 printf(" ippAVX_ENABLEDBYOS = ");
83 printf("%c\t%c\t",
84 (mask & ippAVX_ENABLEDBYOS) ? 'Y' : 'N',
85 (emask & ippAVX_ENABLEDBYOS) ? 'Y' : 'N');
86 printf("The operating system supports Intel(R) AVX\n");
87 printf(" ippCPUID_AES = ");
88 printf("%c\t%c\t", (mask & ippCPUID_AES) ? 'Y' : 'N', (emask & ippCPUID_AES) ? 'Y' : 'N');
89 printf("Intel(R) Advanced Encryption Standard New Instructions (Intel(R) AES-NI)\n");
90 printf(" ippCPUID_SHA = ");
91 printf("%c\t%c\t", (mask & ippCPUID_SHA) ? 'Y' : 'N', (emask & ippCPUID_SHA) ? 'Y' : 'N');
92 printf("Intel(R) Secure Hash Algorithm - New Instructions (Intel(R) SHA-NI)\n");
93 printf(" ippCPUID_CLMUL = ");
94 printf("%c\t%c\t",
95 (mask & ippCPUID_CLMUL) ? 'Y' : 'N',
96 (emask & ippCPUID_CLMUL) ? 'Y' : 'N');
97 printf("PCLMULQDQ instruction\n");
98 printf(" ippCPUID_RDRAND = ");
99 printf("%c\t%c\t",
100 (mask & ippCPUID_RDRAND) ? 'Y' : 'N',
101 (emask & ippCPUID_RDRAND) ? 'Y' : 'N');
102 printf("Read Random Number instructions\n");
103 printf(" ippCPUID_F16C = ");
104 printf("%c\t%c\t", (mask & ippCPUID_F16C) ? 'Y' : 'N', (emask & ippCPUID_F16C) ? 'Y' : 'N');
105 printf("Float16 instructions\n");
106 printf(" ippCPUID_AVX2 = ");
107 printf("%c\t%c\t", (mask & ippCPUID_AVX2) ? 'Y' : 'N', (emask & ippCPUID_AVX2) ? 'Y' : 'N');
108 printf("Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) instruction set\n");
109 printf(" ippCPUID_AVX512F = ");
110 printf("%c\t%c\t",
111 (mask & ippCPUID_AVX512F) ? 'Y' : 'N',
112 (emask & ippCPUID_AVX512F) ? 'Y' : 'N');
113 printf("Intel(R) Advanced Vector Extensions 3.1 instruction set\n");
114 printf(" ippCPUID_AVX512CD = ");
115 printf("%c\t%c\t",
116 (mask & ippCPUID_AVX512CD) ? 'Y' : 'N',
117 (emask & ippCPUID_AVX512CD) ? 'Y' : 'N');
118 printf("Intel(R) Advanced Vector Extensions CD (Conflict Detection) instruction set\n");
119 printf(" ippCPUID_AVX512ER = ");
120 printf("%c\t%c\t",
121 (mask & ippCPUID_AVX512ER) ? 'Y' : 'N',
122 (emask & ippCPUID_AVX512ER) ? 'Y' : 'N');
123 printf("Intel(R) Advanced Vector Extensions ER instruction set\n");
124 printf(" ippCPUID_ADCOX = ");
125 printf("%c\t%c\t",
126 (mask & ippCPUID_ADCOX) ? 'Y' : 'N',
127 (emask & ippCPUID_ADCOX) ? 'Y' : 'N');
128 printf("ADCX and ADOX instructions\n");
129 printf(" ippCPUID_RDSEED = ");
130 printf("%c\t%c\t",
131 (mask & ippCPUID_RDSEED) ? 'Y' : 'N',
132 (emask & ippCPUID_RDSEED) ? 'Y' : 'N');
133 printf("The RDSEED instruction\n");
134 printf(" ippCPUID_PREFETCHW = ");
135 printf("%c\t%c\t",
136 (mask & ippCPUID_PREFETCHW) ? 'Y' : 'N',
137 (emask & ippCPUID_PREFETCHW) ? 'Y' : 'N');
138 printf("The PREFETCHW instruction\n");
139 printf(" ippCPUID_KNC = ");
140 printf("%c\t%c\t", (mask & ippCPUID_KNC) ? 'Y' : 'N', (emask & ippCPUID_KNC) ? 'Y' : 'N');
141 printf("Intel(R) Xeon Phi™ coprocessor instruction set\n");
142 }
143
144 PRINT_EXAMPLE_STATUS(
145 "ippcpGetCpuFeatures",
146 "Demonstration of cryptoGetLibVersion and ippcpGetCpuFeatures functions work",
147 ippStsNoErr == status);
148 return status;
149 }