mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: unit: atomic: cleanup unsigned types
Use unsigned values where values are logically always positive. JIRA NVGPU-2251 Change-Id: Id5169a1428e834a32624613654a14f0510e366a2 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2079377 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
2c88cd50a4
commit
0cd6bf1c4f
@@ -52,15 +52,15 @@ struct atomic_test_args {
|
|||||||
enum atomic_op op;
|
enum atomic_op op;
|
||||||
enum atomic_type type;
|
enum atomic_type type;
|
||||||
long start_val;
|
long start_val;
|
||||||
long loop_count;
|
unsigned long loop_count;
|
||||||
long value; /* for add/sub ops */
|
unsigned long value; /* absolute value */
|
||||||
};
|
};
|
||||||
struct atomic_thread_info {
|
struct atomic_thread_info {
|
||||||
struct atomic_struct *atomic;
|
struct atomic_struct *atomic;
|
||||||
struct atomic_test_args *margs;
|
struct atomic_test_args *margs;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
int thread_num;
|
unsigned int thread_num;
|
||||||
int iterations;
|
unsigned int iterations;
|
||||||
long final_val;
|
long final_val;
|
||||||
long unless;
|
long unless;
|
||||||
};
|
};
|
||||||
@@ -428,14 +428,14 @@ static int test_atomic_set_and_read(struct unit_module *m,
|
|||||||
struct gk20a *g, void *__args)
|
struct gk20a *g, void *__args)
|
||||||
{
|
{
|
||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
const int loop_limit = args->type == ATOMIC_32 ? (sizeof(int) * 8) :
|
const unsigned int loop_limit = args->type == ATOMIC_32 ?
|
||||||
(sizeof(long) * 8);
|
(sizeof(int) * 8) : (sizeof(long) * 8);
|
||||||
const long min_value = args->type == ATOMIC_32 ? INT_MIN :
|
const long min_value = args->type == ATOMIC_32 ? INT_MIN :
|
||||||
LONG_MIN;
|
LONG_MIN;
|
||||||
const long max_value = args->type == ATOMIC_32 ? INT_MAX :
|
const long max_value = args->type == ATOMIC_32 ? INT_MAX :
|
||||||
LONG_MAX;
|
LONG_MAX;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
single_set_and_read(m, &atomic, args->type, min_value);
|
single_set_and_read(m, &atomic, args->type, min_value);
|
||||||
single_set_and_read(m, &atomic, args->type, max_value);
|
single_set_and_read(m, &atomic, args->type, max_value);
|
||||||
@@ -466,7 +466,7 @@ static int test_atomic_arithmetic(struct unit_module *m,
|
|||||||
{
|
{
|
||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
int i;
|
unsigned int i;
|
||||||
long delta_magnitude;
|
long delta_magnitude;
|
||||||
long read_val;
|
long read_val;
|
||||||
long expected_val;
|
long expected_val;
|
||||||
@@ -555,7 +555,7 @@ static int test_atomic_arithmetic(struct unit_module *m,
|
|||||||
static void *arithmetic_thread(void *__args)
|
static void *arithmetic_thread(void *__args)
|
||||||
{
|
{
|
||||||
struct atomic_thread_info *targs = (struct atomic_thread_info *)__args;
|
struct atomic_thread_info *targs = (struct atomic_thread_info *)__args;
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
pthread_barrier_wait(&thread_barrier);
|
pthread_barrier_wait(&thread_barrier);
|
||||||
|
|
||||||
@@ -635,10 +635,10 @@ static void *arithmetic_thread(void *__args)
|
|||||||
*/
|
*/
|
||||||
static bool correct_thread_iteration_count(struct unit_module *m,
|
static bool correct_thread_iteration_count(struct unit_module *m,
|
||||||
struct atomic_thread_info *threads,
|
struct atomic_thread_info *threads,
|
||||||
int num_threads,
|
unsigned int num_threads,
|
||||||
long expected_iterations)
|
long expected_iterations)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
long total_iterations = 0;
|
long total_iterations = 0;
|
||||||
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
for (i = 0; i < num_threads; i++) {
|
||||||
@@ -670,9 +670,9 @@ static int test_atomic_arithmetic_threaded(struct unit_module *m,
|
|||||||
{
|
{
|
||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
const int num_threads = 100;
|
const unsigned int num_threads = 100;
|
||||||
struct atomic_thread_info threads[num_threads];
|
struct atomic_thread_info threads[num_threads];
|
||||||
int i;
|
unsigned int i;
|
||||||
long expected_val, val, expected_iterations;
|
long expected_val, val, expected_iterations;
|
||||||
int ret = UNIT_SUCCESS;
|
int ret = UNIT_SUCCESS;
|
||||||
|
|
||||||
@@ -772,7 +772,7 @@ static int test_atomic_arithmetic_threaded(struct unit_module *m,
|
|||||||
bool sequential = true;
|
bool sequential = true;
|
||||||
for (i = 0; i < (num_threads - 1); i++) {
|
for (i = 0; i < (num_threads - 1); i++) {
|
||||||
if (abs(threads[i].final_val - threads[i+1].final_val)
|
if (abs(threads[i].final_val - threads[i+1].final_val)
|
||||||
!= args->loop_count) {
|
!= (long)args->loop_count) {
|
||||||
sequential = false;
|
sequential = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -801,7 +801,7 @@ static int test_atomic_xchg(struct unit_module *m,
|
|||||||
{
|
{
|
||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
int i;
|
unsigned int i;
|
||||||
long new_val, old_val, ret_val;
|
long new_val, old_val, ret_val;
|
||||||
|
|
||||||
if (single_set_and_read(m, &atomic, args->type, args->start_val)
|
if (single_set_and_read(m, &atomic, args->type, args->start_val)
|
||||||
@@ -841,7 +841,7 @@ static int test_atomic_cmpxchg(struct unit_module *m,
|
|||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
const int switch_interval = 5;
|
const int switch_interval = 5;
|
||||||
int i;
|
unsigned int i;
|
||||||
long new_val, old_val, ret_val;
|
long new_val, old_val, ret_val;
|
||||||
bool should_match = true;
|
bool should_match = true;
|
||||||
|
|
||||||
@@ -915,7 +915,7 @@ static int test_atomic_add_unless(struct unit_module *m,
|
|||||||
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
struct atomic_test_args *args = (struct atomic_test_args *)__args;
|
||||||
struct atomic_struct atomic = {0};
|
struct atomic_struct atomic = {0};
|
||||||
const int switch_interval = 5;
|
const int switch_interval = 5;
|
||||||
int i;
|
unsigned int i;
|
||||||
int new_val, old_val, ret_val;
|
int new_val, old_val, ret_val;
|
||||||
bool should_update = true;
|
bool should_update = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user