@@ -255,6 +255,9 @@ PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = 0;
255255// VK_NV_cooperative_matrix
256256PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0 ;
257257
258+ // VK_NV_cooperative_vector
259+ PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV vkGetPhysicalDeviceCooperativeVectorPropertiesNV = 0 ;
260+
258261class GpuInfoPrivate
259262{
260263public:
@@ -358,6 +361,7 @@ class GpuInfoPrivate
358361 int support_VK_ANDROID_external_memory_android_hardware_buffer;
359362#endif // __ANDROID_API__ >= 26
360363 int support_VK_NV_cooperative_matrix;
364+ int support_VK_NV_cooperative_vector;
361365
362366 // extension features
363367 void * queryExtensionFeatures;
@@ -374,6 +378,7 @@ class GpuInfoPrivate
374378 VkPhysicalDeviceShaderSubgroupRotateFeaturesKHR queryShaderSubgroupRotateFeatures;
375379 VkPhysicalDeviceShaderAtomicFloatFeaturesEXT queryShaderAtomicFloatFeatures;
376380 VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT queryShaderAtomicFloat2Features;
381+ VkPhysicalDeviceCooperativeVectorFeaturesNV queryCooperativeVectorFeaturesNV;
377382
378383 // extension properties
379384 void * queryExtensionProperties;
@@ -382,10 +387,12 @@ class GpuInfoPrivate
382387 VkPhysicalDeviceSubgroupProperties querySubgroupProperties;
383388 VkPhysicalDeviceDriverPropertiesKHR queryDriverProperties;
384389 VkPhysicalDeviceSubgroupSizeControlPropertiesEXT querySubgroupSizeControlProperties;
390+ VkPhysicalDeviceCooperativeVectorPropertiesNV queryCooperativeVectorPropertiesNV;
385391
386392 // extension sub properties
387393 std::vector<VkCooperativeMatrixPropertiesKHR> queryCooperativeMatrixSubProperties;
388394 std::vector<VkCooperativeMatrixPropertiesNV> queryCooperativeMatrixSubPropertiesNV;
395+ std::vector<VkCooperativeVectorPropertiesNV> queryCooperativeVectorSubPropertiesNV;
389396};
390397
391398void GpuInfoPrivate::query_features ()
@@ -707,6 +714,7 @@ int GpuInfoPrivate::query_extensions()
707714 support_VK_ANDROID_external_memory_android_hardware_buffer = 0 ;
708715#endif // __ANDROID_API__ >= 26
709716 support_VK_NV_cooperative_matrix = 0 ;
717+ support_VK_NV_cooperative_vector = 0 ;
710718 for (uint32_t j = 0 ; j < deviceExtensionPropertyCount; j++)
711719 {
712720 const VkExtensionProperties& exp = deviceExtensionProperties[j];
@@ -794,6 +802,8 @@ int GpuInfoPrivate::query_extensions()
794802#endif // __ANDROID_API__ >= 26
795803 else if (strcmp (exp.extensionName , " VK_NV_cooperative_matrix" ) == 0 )
796804 support_VK_NV_cooperative_matrix = exp.specVersion ;
805+ else if (strcmp (exp.extensionName , " VK_NV_cooperative_vector" ) == 0 )
806+ support_VK_NV_cooperative_vector = exp.specVersion ;
797807 }
798808
799809 if (support_VK_KHR_buffer_device_address)
@@ -945,6 +955,16 @@ void GpuInfoPrivate::query_extension_features()
945955 queryExtensionFeatures = &queryShaderAtomicFloat2Features;
946956 }
947957
958+ // query nv cooperative vector
959+ memset (&queryCooperativeVectorFeaturesNV, 0 , sizeof (queryCooperativeVectorFeaturesNV));
960+ queryCooperativeVectorFeaturesNV.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_VECTOR_FEATURES_NV ;
961+ queryCooperativeVectorFeaturesNV.pNext = 0 ;
962+ if (support_VK_NV_cooperative_vector)
963+ {
964+ queryCooperativeVectorFeaturesNV.pNext = queryExtensionFeatures;
965+ queryExtensionFeatures = &queryCooperativeVectorFeaturesNV;
966+ }
967+
948968 if (support_VK_KHR_get_physical_device_properties2)
949969 {
950970 VkPhysicalDeviceFeatures2KHR queryFeatures;
@@ -1050,6 +1070,16 @@ void GpuInfoPrivate::query_extension_properties()
10501070 queryExtensionProperties = &querySubgroupSizeControlProperties;
10511071 }
10521072
1073+ // query nv cooperative vector
1074+ memset (&queryCooperativeVectorPropertiesNV, 0 , sizeof (queryCooperativeVectorPropertiesNV));
1075+ queryCooperativeVectorPropertiesNV.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_VECTOR_PROPERTIES_NV ;
1076+ queryCooperativeVectorPropertiesNV.pNext = 0 ;
1077+ if (support_VK_NV_cooperative_vector)
1078+ {
1079+ queryCooperativeVectorPropertiesNV.pNext = queryExtensionProperties;
1080+ queryExtensionProperties = &queryCooperativeVectorPropertiesNV;
1081+ }
1082+
10531083 if (support_VK_KHR_get_physical_device_properties2)
10541084 {
10551085 VkPhysicalDeviceProperties2KHR queryProperties;
@@ -1197,6 +1227,37 @@ void GpuInfoPrivate::query_extension_properties()
11971227 }
11981228 }
11991229
1230+ // query supported cooperative vector types and operations
1231+ queryCooperativeVectorSubPropertiesNV.clear ();
1232+ if (support_VK_NV_cooperative_vector && queryCooperativeVectorFeaturesNV.cooperativeVector )
1233+ {
1234+ uint32_t propertyCount = 0 ;
1235+ VkResult ret = vkGetPhysicalDeviceCooperativeVectorPropertiesNV (physicalDevice, &propertyCount, 0 );
1236+ if (ret != VK_SUCCESS )
1237+ {
1238+ NCNN_LOGE (" vkGetPhysicalDeviceCooperativeVectorPropertiesNV failed %d" , ret);
1239+ }
1240+
1241+ queryCooperativeVectorSubPropertiesNV.resize (propertyCount);
1242+ for (uint32_t j = 0 ; j < propertyCount; j++)
1243+ {
1244+ memset (&queryCooperativeVectorSubPropertiesNV[j], 0 , sizeof (queryCooperativeVectorSubPropertiesNV[j]));
1245+ queryCooperativeVectorSubPropertiesNV[j].sType = VK_STRUCTURE_TYPE_COOPERATIVE_VECTOR_PROPERTIES_NV ;
1246+ queryCooperativeVectorSubPropertiesNV[j].pNext = 0 ;
1247+ }
1248+ ret = vkGetPhysicalDeviceCooperativeVectorPropertiesNV (physicalDevice, &propertyCount, queryCooperativeVectorSubPropertiesNV.data ());
1249+ if (ret != VK_SUCCESS )
1250+ {
1251+ NCNN_LOGE (" vkGetPhysicalDeviceCooperativeVectorPropertiesNV failed %d" , ret);
1252+ }
1253+
1254+ for (uint32_t j = 0 ; j < propertyCount; j++)
1255+ {
1256+ const VkCooperativeVectorPropertiesNV& cvp = queryCooperativeVectorSubPropertiesNV[j];
1257+ // NCNN_LOGE("cvp %d %d %d %d %d %d", cvp.inputType, cvp.inputInterpretation, cvp.matrixInterpretation, cvp.biasInterpretation, cvp.resultType, cvp.transpose);
1258+ }
1259+ }
1260+
12001261 if (queryDriverProperties.driverID == VK_DRIVER_ID_MESA_TURNIP )
12011262 {
12021263 // turnip crash when compiling large shader with full subgroup
@@ -1766,6 +1827,11 @@ int GpuInfo::support_VK_NV_cooperative_matrix() const
17661827 return d->support_VK_NV_cooperative_matrix ;
17671828}
17681829
1830+ int GpuInfo::support_VK_NV_cooperative_vector () const
1831+ {
1832+ return d->support_VK_NV_cooperative_vector ;
1833+ }
1834+
17691835const void * GpuInfo::queryExtensionFeatures () const
17701836{
17711837 return d->queryExtensionFeatures ;
@@ -1841,6 +1907,11 @@ const VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT& GpuInfo::queryShaderAtomicF
18411907 return d->queryShaderAtomicFloat2Features ;
18421908}
18431909
1910+ const VkPhysicalDeviceCooperativeVectorFeaturesNV& GpuInfo::queryCooperativeVectorFeaturesNV () const
1911+ {
1912+ return d->queryCooperativeVectorFeaturesNV ;
1913+ }
1914+
18441915const void * GpuInfo::queryExtensionProperties () const
18451916{
18461917 return d->queryExtensionProperties ;
@@ -1866,6 +1937,11 @@ const VkPhysicalDeviceSubgroupSizeControlPropertiesEXT& GpuInfo::querySubgroupSi
18661937 return d->querySubgroupSizeControlProperties ;
18671938}
18681939
1940+ const VkPhysicalDeviceCooperativeVectorPropertiesNV& GpuInfo::queryCooperativeVectorPropertiesNV () const
1941+ {
1942+ return d->queryCooperativeVectorPropertiesNV ;
1943+ }
1944+
18691945const std::vector<VkCooperativeMatrixPropertiesKHR>& GpuInfo::queryCooperativeMatrixSubProperties () const
18701946{
18711947 return d->queryCooperativeMatrixSubProperties ;
@@ -1876,6 +1952,11 @@ const std::vector<VkCooperativeMatrixPropertiesNV>& GpuInfo::queryCooperativeMat
18761952 return d->queryCooperativeMatrixSubPropertiesNV ;
18771953}
18781954
1955+ const std::vector<VkCooperativeVectorPropertiesNV>& GpuInfo::queryCooperativeVectorSubPropertiesNV () const
1956+ {
1957+ return d->queryCooperativeVectorSubPropertiesNV ;
1958+ }
1959+
18791960static int init_instance_core ()
18801961{
18811962 vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers)vkGetInstanceProcAddr (g_instance, " vkAllocateCommandBuffers" );
@@ -2026,6 +2107,11 @@ static int init_instance_extension()
20262107 vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)vkGetInstanceProcAddr (g_instance, " vkGetPhysicalDeviceCooperativeMatrixPropertiesNV" );
20272108 }
20282109
2110+ // VK_NV_cooperative_vector
2111+ {
2112+ vkGetPhysicalDeviceCooperativeVectorPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV)vkGetInstanceProcAddr (g_instance, " vkGetPhysicalDeviceCooperativeVectorPropertiesNV" );
2113+ }
2114+
20292115 return 0 ;
20302116}
20312117
@@ -4068,6 +4154,12 @@ int VulkanDevice::init_device_extension()
40684154 }
40694155#endif // __ANDROID_API__ >= 26
40704156
4157+ if (info.support_VK_NV_cooperative_vector ())
4158+ {
4159+ vkCmdConvertCooperativeVectorMatrixNV = (PFN_vkCmdConvertCooperativeVectorMatrixNV)vkGetDeviceProcAddr (d->device , " vkCmdConvertCooperativeVectorMatrixNV" );
4160+ vkConvertCooperativeVectorMatrixNV = (PFN_vkConvertCooperativeVectorMatrixNV)vkGetDeviceProcAddr (d->device , " vkConvertCooperativeVectorMatrixNV" );
4161+ }
4162+
40714163 return 0 ;
40724164}
40734165
0 commit comments