You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cpuid_ia64.c 4.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <sys/sysinfo.h>
  41. #include "cpuid.h"
  42. #ifdef __ECC
  43. #include <ia64intrin.h>
  44. #endif
  45. static inline unsigned long cpuid(unsigned long regnum){
  46. unsigned long value;
  47. #ifdef __ECC
  48. value = __getIndReg(_IA64_REG_INDR_CPUID, regnum);
  49. #else
  50. asm ("mov %0=cpuid[%r1]" : "=r"(value) : "rO"(regnum));
  51. #endif
  52. return value;
  53. }
  54. int have_cpuid(void){ return 1;}
  55. int get_vendor(void){
  56. unsigned long cpuid0, cpuid1;
  57. char vendor[18];
  58. cpuid0 = cpuid(0);
  59. cpuid1 = cpuid(1);
  60. *(unsigned long *)(&vendor[0]) = cpuid0;
  61. *(unsigned long *)(&vendor[8]) = cpuid1;
  62. vendor[17] = (char)0;
  63. if (!strcmp(vendor, "GenuineIntel")) return VENDOR_INTEL;
  64. return VENDOR_UNKNOWN;
  65. }
  66. int get_cputype(int gettype){
  67. unsigned long cpuid3;
  68. cpuid3 = cpuid(3);
  69. switch (gettype) {
  70. case GET_ARCHREV :
  71. return BITMASK(cpuid3, 32, 0xff);
  72. case GET_FAMILY :
  73. return BITMASK(cpuid3, 24, 0xff);
  74. case GET_MODEL :
  75. return BITMASK(cpuid3, 16, 0xff);
  76. case GET_REVISION :
  77. return BITMASK(cpuid3, 8, 0xff);
  78. case GET_NUMBER :
  79. return BITMASK(cpuid3, 0, 0xff);
  80. }
  81. return 0;
  82. }
  83. char *get_cpunamechar(void){
  84. if (get_cputype(GET_FAMILY) == 0x07) return "ITANIUM";
  85. if (get_cputype(GET_FAMILY) == 0x1f) return "ITANIUM2";
  86. if (get_cputype(GET_FAMILY) == 0x20) return "ITANIUM2";
  87. return "UNKNOWN";
  88. }
  89. char *get_libname(void){
  90. if (get_cputype(GET_FAMILY) == 0x07) { printf("itanium"); return NULL;}
  91. if (get_cputype(GET_FAMILY) == 0x1f) { printf("itanium2"); return NULL;}
  92. if (get_cputype(GET_FAMILY) == 0x20) { printf("itanium2"); return NULL;}
  93. printf("UNKNOWN");
  94. return NULL;
  95. }
  96. void get_architecture(void){
  97. printf("IA64");
  98. }
  99. void get_subarchitecture(void){
  100. printf("%s", get_cpunamechar());
  101. }
  102. void get_subdirname(void){
  103. printf("ia64");
  104. }
  105. void get_cpuconfig(void){
  106. printf("#define %s\n", get_cpunamechar());
  107. printf("#define L1_DATA_SIZE 262144\n");
  108. printf("#define L1_DATA_LINESIZE 128\n");
  109. printf("#define L2_SIZE 1572864\n");
  110. printf("#define L2_LINESIZE 128\n");
  111. printf("#define DTB_SIZE 16384\n");
  112. printf("#define DTB_ENTRIES 128\n");
  113. }

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.