[PATCH] D36868: [GPGPU] Do not create copy statements when targetting managed memory

Siddharth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 04:51:15 PDT 2017


bollu accepted this revision.
bollu added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: lib/CodeGen/PPCGCodeGeneration.cpp:3143
     } else {
-      Schedule = map_to_device(PPCGGen, Schedule);
+      Schedule = map_to_device(PPCGGen, Schedule, !PollyManagedMemory);
       PPCGGen->tree = generate_code(PPCGGen, isl_schedule_copy(Schedule));
----------------
Consider either:

```lang=cpp
Schedule = map_to_device(PPCGGen, Schedule, /*to_from_device=*/ !PollyManagedMemory);
```

or

```lang=cpp
const bool CreateTransferToFromDevice = !PollyManagedMemory;
Schedule = map_to_device(PPCGGen, Schedule, CreateTransferToFromDevice);
```



================
Comment at: lib/External/ppcg/gpu.c:5280
 __isl_give isl_schedule *map_to_device(struct gpu_gen *gen,
-	__isl_take isl_schedule *schedule)
+	__isl_take isl_schedule *schedule, int to_from_device)
 {
----------------
Could you please document why this is necessary in the comment above?


================
Comment at: lib/External/ppcg/gpu.c:5683
 	} else {
-		schedule = map_to_device(gen, schedule);
+		schedule = map_to_device(gen, schedule, 1);
 		gen->tree = generate_code(gen, schedule);
----------------
Personal opinion: I don't like magic constants. Consider:

```lang=cpp
const int create_transfer_to_from_device = 1;
schedule = map_to_device(gen, schedule, create_transfer_to_from_device);
```

or something along those lines.


https://reviews.llvm.org/D36868





More information about the llvm-commits mailing list