Re: [Mesa-dev] [PATCH 1/4] util/radv: move *_get_function_timestamp() to utils

2017-02-21 Thread Nicolai Hähnle

On 21.02.2017 10:16, Timothy Arceri wrote:

On 21/02/17 19:54, Nicolai Hähnle wrote:

On 20.02.2017 01:15, Timothy Arceri wrote:

V2: The functions we are now sharing used different return values
update the callers to reflect the new common api.


Wasn't there a similar patch on the list recently that also had an anv
part?


Yes but they switched to using build-id [1]. For now I've decided to
stick with this because I'm not sure if it will just work with llvm (I
really haven't bothered looking) and also to wait and see if they hit
any other issues, bsd problems etc.


Okay, makes sense. For LLVM, we might have to change the way LLVM is 
built, and especially for older versions that is out of the question.


So this patch is

Reviewed-by: Nicolai Hähnle 




[1]
https://cgit.freedesktop.org/mesa/mesa/commit/?id=656e30b6860461b2bd725590488126d5e7e10ec1




Cheers,
Nicolai


---
 src/amd/vulkan/radv_device.c | 22 +++---
 src/util/disk_cache.h| 17 +
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 6f2fac2..8cd21c4 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -25,14 +25,13 @@
  * IN THE SOFTWARE.
  */

-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "radv_private.h"
 #include "radv_cs.h"
+#include "util/disk_cache.h"
 #include "util/strtod.h"

 #include 
@@ -47,28 +46,13 @@
 struct radv_dispatch_table dtable;

 static int
-radv_get_function_timestamp(void *ptr, uint32_t* timestamp)
-{
-Dl_info info;
-struct stat st;
-if (!dladdr(ptr, ) || !info.dli_fname) {
-return -1;
-}
-if (stat(info.dli_fname, )) {
-return -1;
-}
-*timestamp = st.st_mtim.tv_sec;
-return 0;
-}
-
-static int
 radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
 {
 uint32_t mesa_timestamp, llvm_timestamp;
 uint16_t f = family;
 memset(uuid, 0, VK_UUID_SIZE);
-if (radv_get_function_timestamp(radv_device_get_cache_uuid,
_timestamp) ||
-radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo,
_timestamp))
+if
(!disk_cache_get_function_timestamp(radv_device_get_cache_uuid,
_timestamp) ||
+
!disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo,
_timestamp))
 return -1;

 memcpy(uuid, _timestamp, 4);
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 7c15aa1..8b6fc0d 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -24,8 +24,10 @@
 #ifndef DISK_CACHE_H
 #define DISK_CACHE_H

+#include 
 #include 
 #include 
+#include 

 #ifdef __cplusplus
 extern "C" {
@@ -38,6 +40,21 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];

 struct disk_cache;

+static inline bool
+disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
+{
+Dl_info info;
+struct stat st;
+if (!dladdr(ptr, ) || !info.dli_fname) {
+return false;
+}
+if (stat(info.dli_fname, )) {
+return false;
+}
+*timestamp = st.st_mtim.tv_sec;
+return true;
+}
+
 /* Provide inlined stub functions if the shader cache is disabled. */

 #ifdef ENABLE_SHADER_CACHE





___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] util/radv: move *_get_function_timestamp() to utils

2017-02-21 Thread Timothy Arceri



On 21/02/17 19:54, Nicolai Hähnle wrote:

On 20.02.2017 01:15, Timothy Arceri wrote:

V2: The functions we are now sharing used different return values
update the callers to reflect the new common api.


Wasn't there a similar patch on the list recently that also had an anv
part?


Yes but they switched to using build-id [1]. For now I've decided to 
stick with this because I'm not sure if it will just work with llvm (I 
really haven't bothered looking) and also to wait and see if they hit 
any other issues, bsd problems etc.



[1] 
https://cgit.freedesktop.org/mesa/mesa/commit/?id=656e30b6860461b2bd725590488126d5e7e10ec1




Cheers,
Nicolai


---
 src/amd/vulkan/radv_device.c | 22 +++---
 src/util/disk_cache.h| 17 +
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 6f2fac2..8cd21c4 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -25,14 +25,13 @@
  * IN THE SOFTWARE.
  */

-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "radv_private.h"
 #include "radv_cs.h"
+#include "util/disk_cache.h"
 #include "util/strtod.h"

 #include 
@@ -47,28 +46,13 @@
 struct radv_dispatch_table dtable;

 static int
-radv_get_function_timestamp(void *ptr, uint32_t* timestamp)
-{
-Dl_info info;
-struct stat st;
-if (!dladdr(ptr, ) || !info.dli_fname) {
-return -1;
-}
-if (stat(info.dli_fname, )) {
-return -1;
-}
-*timestamp = st.st_mtim.tv_sec;
-return 0;
-}
-
-static int
 radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
 {
 uint32_t mesa_timestamp, llvm_timestamp;
 uint16_t f = family;
 memset(uuid, 0, VK_UUID_SIZE);
-if (radv_get_function_timestamp(radv_device_get_cache_uuid,
_timestamp) ||
-radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo,
_timestamp))
+if
(!disk_cache_get_function_timestamp(radv_device_get_cache_uuid,
_timestamp) ||
+
!disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo,
_timestamp))
 return -1;

 memcpy(uuid, _timestamp, 4);
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 7c15aa1..8b6fc0d 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -24,8 +24,10 @@
 #ifndef DISK_CACHE_H
 #define DISK_CACHE_H

+#include 
 #include 
 #include 
+#include 

 #ifdef __cplusplus
 extern "C" {
@@ -38,6 +40,21 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];

 struct disk_cache;

+static inline bool
+disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
+{
+Dl_info info;
+struct stat st;
+if (!dladdr(ptr, ) || !info.dli_fname) {
+return false;
+}
+if (stat(info.dli_fname, )) {
+return false;
+}
+*timestamp = st.st_mtim.tv_sec;
+return true;
+}
+
 /* Provide inlined stub functions if the shader cache is disabled. */

 #ifdef ENABLE_SHADER_CACHE




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] util/radv: move *_get_function_timestamp() to utils

2017-02-21 Thread Nicolai Hähnle

On 20.02.2017 01:15, Timothy Arceri wrote:

V2: The functions we are now sharing used different return values
update the callers to reflect the new common api.


Wasn't there a similar patch on the list recently that also had an anv part?

Cheers,
Nicolai


---
 src/amd/vulkan/radv_device.c | 22 +++---
 src/util/disk_cache.h| 17 +
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 6f2fac2..8cd21c4 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -25,14 +25,13 @@
  * IN THE SOFTWARE.
  */

-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "radv_private.h"
 #include "radv_cs.h"
+#include "util/disk_cache.h"
 #include "util/strtod.h"

 #include 
@@ -47,28 +46,13 @@
 struct radv_dispatch_table dtable;

 static int
-radv_get_function_timestamp(void *ptr, uint32_t* timestamp)
-{
-   Dl_info info;
-   struct stat st;
-   if (!dladdr(ptr, ) || !info.dli_fname) {
-   return -1;
-   }
-   if (stat(info.dli_fname, )) {
-   return -1;
-   }
-   *timestamp = st.st_mtim.tv_sec;
-   return 0;
-}
-
-static int
 radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
 {
uint32_t mesa_timestamp, llvm_timestamp;
uint16_t f = family;
memset(uuid, 0, VK_UUID_SIZE);
-   if (radv_get_function_timestamp(radv_device_get_cache_uuid, 
_timestamp) ||
-   radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, 
_timestamp))
+   if (!disk_cache_get_function_timestamp(radv_device_get_cache_uuid, 
_timestamp) ||
+   !disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, 
_timestamp))
return -1;

memcpy(uuid, _timestamp, 4);
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 7c15aa1..8b6fc0d 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -24,8 +24,10 @@
 #ifndef DISK_CACHE_H
 #define DISK_CACHE_H

+#include 
 #include 
 #include 
+#include 

 #ifdef __cplusplus
 extern "C" {
@@ -38,6 +40,21 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];

 struct disk_cache;

+static inline bool
+disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
+{
+   Dl_info info;
+   struct stat st;
+   if (!dladdr(ptr, ) || !info.dli_fname) {
+   return false;
+   }
+   if (stat(info.dli_fname, )) {
+   return false;
+   }
+   *timestamp = st.st_mtim.tv_sec;
+   return true;
+}
+
 /* Provide inlined stub functions if the shader cache is disabled. */

 #ifdef ENABLE_SHADER_CACHE



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev